You are currently viewing the BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
I am having a similar problem. Having downlaoded and written the script on p369 separately I still can't get it to work. Running on SuSE with apache. Upon clicking the upload button after selecting a file nothing happens.
Okay, so now's the time to be more specific about your problem. What errors, if any, are you seeing? What are the active configuration settings? How big a file are you trying to upload?
If you're not seeing any errors, check the following PHP config values:
error_reporting (should be E_ALL)
display_errors (should be on)
display_startup_errors (should be on)
max_execution_time (should be large enough to support the largest
file uploads from a reasonable connection)
Also, check that file_uploads is "on". If you want to use the system default tmp dir, make sure that upload_tmp_dir is undefined (i.e. commented out).
What errors, if any, are you seeing? None
Filesize- tried a few files - usually quite small- couple of Megs
What are the active configuration settings? Not sure what you mean- is this the /etc/php.ini
The error reporting setting were already on the variables you suggested and I still don't see any errors???
file_uploads and max_execution_time are on the variables you suggested as well.
Wait a minute -- you said in your first post you're having similar problems as the original poster. He was seeing a permission error. Now you're saying that you don't see ANY errors...?!?
I don't quite follow you.
Please do me a favor and start over -- tell me what you're trying to do. Feel free to post some relevant code snippets. Notice I said "snippets", because posting more than 20-30 lines of code doesn't really make our (the people who are trying to help you) lives easier.
Keep in mind that most people won't want to take more time answering your question than you take to ask it.
Now to respond to your last post:
I'd try uploading a much smaller file to begin with -- say, a very small text file. Nothing larger than 1k.
Your configuration settings are defined in php.ini. If running PHP as an apache module, these settings can be changed in httpd.conf and/or .htaccess files. To check the active settings, run a phpinfo script:
<?php phpinfo(); ?>
This function generates a very long page that states all of PHP's active configuration settings, global variables (including get, post, et. al.), and all the enabled extensions (e.g. GD and XSLT).
In my experience with working with uploading files the size of the file doesn't affect max_execution_time, uploading the file via HTTP the file is sent to the server before PHP execution begins, it isn't till all post data is sent that the script being called on begins execution. I've uploaded files up to a MB over a dial-up connection and never received an error of exceeding the max_execution_time.
However there is another configuration direcive that you should check and that's upload_max_filesize. If you're uploading a file larger than that allowed by this directive then I don't think that you'll see any errors, the script would as you have said simply fail (where the uploaded file is conserned) and not display any errors, if I remember correctly. The default is 2MB. Check the value of this directive you should see it in phpinfo() output, or you can display it by calling ini_get("upload_max_filesize").
Again, as Nik has said, it would be helpful for us to see the code you are using to upload the file.
I'm going to try to write the code from scratch as the code in the book doesn't seem to be working for me. So I'll get back to you when I encounter a problem there.
The problem with the code in the book seems to be that the post form doesn't seem to set the upload file variable. There in this bit of the code
if($action == 'upload') upload_file();
nothing is done and the upload_form function is recalled, because the $action variable isn't being set.
The post form code is
<FORM METHOD="POST" ENCTYPE="MULTIPART/FORM-DATA"
ACTION="<? echo $PHP_SELF ?>">
<INPUT TYPE="HIDDEN" NAME="action" VALUE="upload">
<INPUT TYPE="FILE" NAME="userfile">
<INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="upload">