RE: [PHP-GENERAL] Upload problem with PHP and Windows

From: Date: Tue, 13 Jun 2000 15:49:32 +0000
Subject: RE: [PHP-GENERAL] Upload problem with PHP and Windows
Groups: php.general 
Request: Send a blank email to php-general+get-1722@lists.php.net to get a copy of this message
Hi, see below for a DETAILED problem description (my recent posting on the windows list). You can SOLVE this problem by using "./" as the TMPDIR in php3.ini, however you may not want to have the temporary files in your PHP dir, but this really works! Regards, Sascha Kimmel -----Original Message----- From: PHP [mailto:php@tricos.com] Sent: Monday, June 12, 2000 7:25 PM To: MM; php-windows@lists.php.net Cc: bugs@php.net Subject: RE: Newbie file upload > > Having trouble with a a very straightforward script to upload a file. > > Form page takes file and puts it in "picture" Action is upload.php which > consists of the following code: > > <?php > copy($picture, "images/$picture_name"); > ?> > > I keep getting the following error message: > > "Unable to open 'c:\\windows\\TEMP\\php11' for reading: No such file or > directory in C:\WEBSHARE\WWWROOT\learningPHP\upload.php on line 9" > > What's the problem here? Hi, I guess this is a PHP BUG! I'm using PHP 3.0.11 on Windows 98 with Apache/1.3.12. PHP3.ini is configured the following way: ------X<-------------------------------------------------- [...] ;;;;;;;;;;;;;;;;;;;;;;;;; ; Paths and Directories ; ;;;;;;;;;;;;;;;;;;;;;;;;; [...] upload_tmp_dir = c:\windows\temp [...] ------X<-------------------------------------------------- My Script (i:\websites\gx\gx\template_upload.php3) looks as follows: ------X<-------------------------------------------------- <form> <? /* $userfile - The temporary filename in which the uploaded file was stored on the server machine. $userfile_name - The original name of the file on the sender's system. $userfile_size - The size of the uploaded file in bytes. $userfile_type - The mime type of the file if the browser provided this information. An example would be "image/gif". */ echo "OName: $userfile<br>"; echo "Name: $userfile_name<br>"; echo "Size: $userfile_size<br>"; echo "Type: $userfile_type<br>"; if(1) //if (file_exists($userfile)) { $fp = fopen("$userfile", "r"); while((!feof($fp))) { $cline=fgets($fp, 8192); echo htmlspecialchars($cline); } fclose($fp); } else { echo "Not found!<br>"; } ?> </form> ------X<-------------------------------------------------- As you can see I'm overriding the file-exists-query. After uploading a file the output is: ------X<-------------------------------------------------- OName: c:\\windows\\temp\\php2 Name: sk.de.txt Size: 71 Type: text/plain Warning: fopen("c:\\windows\\temp\\php2","r") - Unknown error in i:\websites\gx\gx\template_upload.php3 on line 18 <br> <b>Warning</b>: Unable to find file identifier 0 in <b>i:\websites\gx\gx\template_upload.php3</b> on line <b>20</b><br> <br> <b>Warning</b>: Unable to find file identifier 0 in <b>i:\websites\gx\gx\template_upload.php3</b> on line <b>25</b><br> ------X<-------------------------------------------------- ----> THIS IS A BUG! <---- The BUG is that PHP does NOT put this temporary file into C:\windows\temp but into i:\ (!!!) I found this out by using the Norton Protection Recycling feature (Unerase-Assistant, NORTON Utilities 2000) which shows many entries "php2", all in i:\ which have been deleted by "PHP" (!!). So PHP is soooo stupid that it puts the temporary file into i:\ (remember: my script is located at i:\websites\gx\gx) (where does it get this info?) and LOOKS for the file in the TEMPDIR! I've set the TEMPDIR to i:\ and what happens? Same thing as before "Warning: fopen("i:\\php2","r") - Unknown error in i:\websites\gx\gx\template_upload.php3 on line 18" although the file is written there (NORTON Unerase tells me) - maybe the writing of that file is not yet ready if the next fopen occurs? Two bugs or one bug? Regards, Sascha Kimmel

« previous php.general (#1722) next »