Page 1 of 1

Trying to make Singup fourm

Posted: Tue Jul 03, 2012 6:35 am
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']);?>"

Re: Trying to make Singup fourm

Posted: Tue Jul 03, 2012 1:36 pm
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?

Re: Trying to make Singup fourm

Posted: Thu Jul 05, 2012 9:53 am
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.