0
Tuesday
22
Mar-2005
Filed Under: PHP, Programming

Use the following code in your target page from the file upload form to handle saving the file on the server:

//set the destination directory$uploaddir = '/var/www/uploads/';//set the destination file name$uploadfile = $uploaddir . $_FILES['userfile']['name'];print('');//move file to designated directory, then test if successfulif (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)){    print('File is valid, and was successfully uploaded. ');    print('Here's some more debugging info:n');    print_r($_FILES);}//show if problems occurelse{    print('Possible file upload attack! Debugging info:n');    print_r($_FILES);}print('');

Link: http://www.php.net/features.file-upload

No Response to "PHP - File Uploading How-To"

Be the first to comment! :)

Share Your Thoughts

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>