Trying to make Singup fourm

Ask about a PHP problem here.
Post Reply
drew1
Posts: 1
Joined: Tue Jul 03, 2012 6:31 am

Trying to make Singup fourm

Post by drew1 »

I am trying to make a registration forum that involves a someone to upload a img at the signup process how do i do that so far i have this and i am doing this right?
<label for"avatar">Avatar:</label>
<input type="file" name="avatar" id="avatar" value"<?php if (isset($_FILES['avatar']);?>"
Last edited by Temor on Tue Jul 03, 2012 1:35 pm, edited 1 time in total.
Reason: Syntax tags
User avatar
Temor
Posts: 1186
Joined: Thu May 05, 2011 8:04 pm

Re: Trying to make Singup fourm

Post by Temor »

Well. That's two lines of code. There is no way to tell if you're doing it right by seeing two lines of code.
Is that all you've got?

Do you know how to make a regular signup form?
User avatar
Helx
Posts: 350
Joined: Thu May 17, 2012 6:45 am
Location: Auckland, New Zealand

Re: Trying to make Singup fourm

Post by Helx »

Not too sure what you're trying to do exactly... But this is the fastest way:

The form:
<form action="avatar_upload.php" enctype="multipart/form-data" method="post">
<input type="hidden" name="max_size" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
Replace the value of "max_size" to a comfortable, safe amount. That value is 100 KB.

The avatar_upload.php file:
$upload_path = "uploads/";

$upload_path = $upload_path . basename( $_FILES['uploadedfile']['name']); 

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $upload_path)) {
    echo "You're avatar was uploaded!";
} else{
    echo "Something went wrong, oh no!";
}
Now, this script was made in 3 minutes.. And there is no safety behind it.
You will need to limit filetypes and more securely hold the filesize limit.
Post Reply