Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP FAQs
|
PHP FAQs This moderated forum is where our PHP experts answer some of the questions they see asked most frequently in the other PHP forums. You cannot post other messages here, use the other PHP forums for that.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP FAQs section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 8th, 2004, 06:03 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default Q. My file upload doesn't work, what's wrong?

Troubleshooting file uploads

1st, read the FAQ entry for uploading a file to make sure you have each component necessary present in your script.

Uploading files to a directory:
http://p2p.wrox.com/topic.asp?TOPIC_ID=12104

Uploading files to a database:
http://p2p.wrox.com/topic.asp?TOPIC_ID=11883

If you are absolutely sure that all the necessary HTML form components are present, Follow each of the steps present in this article in detail:
Go to your php.ini configuration file and locate the following snippet...

Code:
;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;

; Whether to allow HTTP file uploads.
file_uploads = On

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
upload_tmp_dir = C:\PHP\uploadtemp  ; temporary directory for HTTP uploaded files (will use system default if not specified)

; Maximum allowed size for uploaded files.
upload_max_filesize = 2M
Verify that C:\PHP\uploadtemp exists and has the proper write permissions. If the directory does not exist, create it and give it the proper write permissions, or change the value of upload_tmp_dir to another directory and apply the proper write permissions there.

Verify that file uploads are turned on via the file_uploads directive.

Verify that you are not trying to upload a file larger than 2MB in size, or larger than the value specified in upload_max_filesize.

If you can verify each of the above then you will be able to output the $_FILES superglobal after an upload attempt, as in:
Code:
    echo "<pre>";
    var_dump($_FILES);
    echo "</pre>";
If the variable is empty, then there is a problem with one of the above. If the variable contains the various data associated with the file then the problem is elsewhere.

Be sure to restart your HTTP server, if necessary, after applying any php.ini changes.





Similar Threads
Thread Thread Starter Forum Replies Last Post
No such file or directory error for wrong linking awotta BOOK: Professional Assembly Language 1 January 10th, 2010 07:44 AM
Filter File Types in ASP.NET File Upload ramuis78 ASP.NET 2.0 Basics 2 May 31st, 2007 10:50 AM
Whole Folder upload(Multi file Upload) ramasamy_rams XML 1 September 9th, 2005 12:43 PM
display script - zip file - something is wrong? jstewie Javascript How-To 1 August 31st, 2005 02:07 AM
JSP file upload and delete file pandjie JSP Basics 0 January 29th, 2005 10:49 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.