i am working on a project which has user profile and need to upload an avatar. i have no idea on how to code using php the upload avatar function. any idea?
any help would be appreciated! tnx

Recommended Answers

All 8 Replies

i don't think its as easy as you think mate...

On the html you need to add this:
<input type="file" name="uploadFile">

And on the page that checks and stores everything int he database you'll need to add AT LEAST this:

move_uploaded_file ($_FILES['uploadFile'] ['tmp_name'], 
       "../uploads/{$_FILES['uploadFile'] ['name']}")

You really should read the tutorials I posted above... there's no quick way of doing this... because you'll have to check the avatars are within a certain size limit and if not then reduce them etc...

Good luck.

i don't think its as easy as you think mate...

On the html you need to add this:
<input type="file" name="uploadFile">

And on the page that checks and stores everything int he database you'll need to add AT LEAST this:

move_uploaded_file ($_FILES['uploadFile'] ['tmp_name'], 
       "../uploads/{$_FILES['uploadFile'] ['name']}")

You really should read the tutorials I posted above... there's no quick way of doing this... because you'll have to check the avatars are within a certain size limit and if not then reduce them etc...

Good luck.

Not only that but especially with uploads you need verification of the file extension at least. I use ftp storage because I don't believe that any directory should provide the correct permissions to upload to. This also keeps the files away from your docroot just in case a bad file did get past your verification process and leaves that problem with the ftp server admin. PHP has a whole slew of functions for working with ftp which you can probably find just by going to php.net and searching for ftp, they also have a whole section on handling file uploads too.

Not only that but especially with uploads you need verification of the file extension at least. I use ftp storage because I don't believe that any directory should provide the correct permissions to upload to. This also keeps the files away from your docroot just in case a bad file did get past your verification process and leaves that problem with the ftp server admin. PHP has a whole slew of functions for working with ftp which you can probably find just by going to php.net and searching for ftp, they also have a whole section on handling file uploads too.

thanks very much kevindougans.. really appreciated.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.