[PHP] HTTP POST FILE UPLOAD HELP - REVISITED

2002-11-09 Thread @ Darwin
Sorry about that guys, here is a bit more info that might be useful:

I forgot to tell you that I'm working on a Windows XP box with full rights,
which means the default temporary directory is C:\WINDOWS\Temp and there are
no limitations on what I can and cannot access on the system (running as
system administrator). I did change that default to C:\PHP\tmp_uploads. I
ran this script with the default temp directory as well, same result.

I tried the code at http://www.php.net/manual/sk/features.file-upload.php
and listed the results of the test below. I simplified the code a little,
and here it is:

--[clip
start]
?php
if ($submit) {
   if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
   echo The temporary file exists;
   } else {
   echo Possible file upload attack.;
   }
   echo  br Filename:  . $_FILES['userfile']['name']
   . br Mime-Type:  . $_FILES['userfile']['type']
   . br File Size:  . $_FILES['userfile']['size'] .  bytes
   . br Temporary File Name:  . $_FILES['userfile']['tmp_name']
   . br Error:  . $_FILES['userfile']['error'];
} else {

?

form enctype=multipart/form-data action=img_upload.php method=post
input type=hidden name=MAX_FILE_SIZE value=100
Send this file: input name=userfile type=file
input type=submit name=submit value=submit
/form

?php } ?
--[clip
end]


Here is what's happening:

2. When the submit button is pushed, the files are uploaded through the form
but the temporary file is never created on the system. I did a search on the
entire C: drive for the temporary file that should have been created, but
it's not there.


Here is the data received after the file is supposedly uploaded with a GIF
image:
The temporary file exists
Filename: icon_processing.gif
Mime-Type: image/gif
File Size: 408 bytes
Temporary File Name: C:/PHP/tmp_uploads\php93.tmp
Error: 0


Here is the data received after the file is supposedly uploaded with a JPG
image:
The temporary file exists
Filename: Sunset.jpg
Mime-Type: image/pjpeg
File Size: 71189 bytes
Temporary File Name: C:/PHP/tmp_uploads\php95.tmp
Error: 0



NOTE: The error code 0 means that there was no error uploading the file.

THE QUESTION: Shouldn't PHP automatically create a temporary file of the
uploaded image? Is there something I'm missing in the php.ini settings?

If you have any other questions that might help you further your probe into
this problem, please let me know. Thanks...

- Darwin


--[old
message]

 Ok, I have a problem with my file upload. When I upload a file, say $img,
 only $img is available and when I echo $img to the screen it gives the
full
 path of the temporary image supposedly created by PHP. Echoing
 $_FILE['img']['tmp_name'], or any of the other $_FILE array elements,
 doesn't give anything. There is no array of information for the uploaded
 file, possibly because of the following problem I'm having:

 Another weird thing is that no temporary file is even created on the
server
 (I did a system search on the C: drive of the windows box I'm using). Here
 is the info from my php.ini file:

 --
--
 ---

 
 ; 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\tmp_uploads

 ; Maximum allowed size for uploaded files.
 upload_max_filesize = 6M

 --
--
 

 I even changed the upload_tmp_dir setting to the default and it still
didn't
 create a temporary file of the image on the server. GD is definately
 installed and enabled according to phpinfo() -- although GD has nothing to
 do with this. I'm uploading *.jpg/*.jpeg files only. register_globals is
on
 (I am aware of the risks). So what could be wrong? Is there another
setting
 in the php.ini file that I need to worry about that is not set by default?
 I've pondered and tested this long enough and I'm beyond frustration,
 someone please help me with some suggestions to get me through this...

 Thanks,
 - Darwin


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] HTTP POST FILE UPLOAD HELP - REVISITED

2002-11-09 Thread Jason Wong
On Saturday 09 November 2002 18:39, [EMAIL PROTECTED] wrote:
 Sorry about that guys, here is a bit more info that might be useful:

 I forgot to tell you that I'm working on a Windows XP box with full rights,
 which means the default temporary directory is C:\WINDOWS\Temp and there
 are no limitations on what I can and cannot access on the system (running
 as system administrator). I did change that default to C:\PHP\tmp_uploads.
 I ran this script with the default temp directory as well, same result.

Assuming that you webserver really does have access to write to those 
directories then ...

[snip 'simplified' code]

 Here is what's happening:

 2. When the submit button is pushed, the files are uploaded through the
 form but the temporary file is never created on the system. I did a search
 on the entire C: drive for the temporary file that should have been
 created, but it's not there.

... you didn't read the manual like I suggested. Because otherwise you'll know 
that the file will be deleted from the temporary directory at the end of the 
request if it has not been moved away or renamed.

If you didn't 'simplify' the example and removed the all important copy() or 
move_uploaded_file() then you would have had something that worked!

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
Mount St. Helens should have used earth control.
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] HTTP POST FILE UPLOAD HELP - REVISITED

2002-11-09 Thread @ Darwin

You're absolutely correct. The script works perfectly fine now, and I have
you to thank. I went back to Handling file uploads and re-read the entire
thing. I guess I missed the part that said the following before the actual
script example. My fault and my apologies. Thanks Jason, and thanks to all
the others who replied as well.

...Whatever the logic, you should either delete the file from the temporary
directory or move it elsewhere.
The file will be deleted from the temporary directory at the end of the
request if it has not been moved away or renamed.






 -Original Message-
 From: Jason Wong [mailto:php-general;gremlins.com.hk]
 Sent: Saturday, November 09, 2002 5:01 AM
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP] HTTP POST FILE UPLOAD HELP - REVISITED


 On Saturday 09 November 2002 18:39, [EMAIL PROTECTED] wrote:
  Sorry about that guys, here is a bit more info that might be useful:
 
  I forgot to tell you that I'm working on a Windows XP box with
 full rights,
  which means the default temporary directory is C:\WINDOWS\Temp and there
  are no limitations on what I can and cannot access on the
 system (running
  as system administrator). I did change that default to
 C:\PHP\tmp_uploads.
  I ran this script with the default temp directory as well, same result.

 Assuming that you webserver really does have access to write to those
 directories then ...

 [snip 'simplified' code]

  Here is what's happening:
 
  2. When the submit button is pushed, the files are uploaded through the
  form but the temporary file is never created on the system. I
 did a search
  on the entire C: drive for the temporary file that should have been
  created, but it's not there.

 ... you didn't read the manual like I suggested. Because
 otherwise you'll know
 that the file will be deleted from the temporary directory at
 the end of the
 request if it has not been moved away or renamed.

 If you didn't 'simplify' the example and removed the all
 important copy() or
 move_uploaded_file() then you would have had something that worked!

 --
 Jason Wong - Gremlins Associates - www.gremlins.com.hk
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *

 /*
 Mount St. Helens should have used earth control.
 */


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] HTTP POST FILE UPLOAD HELP

2002-11-08 Thread @ Darwin

Ok, I have a problem with my file upload. When I upload a file, say $img,
only $img is available and when I echo $img to the screen it gives the full
path of the temporary image supposedly created by PHP. Echoing
$_FILE['img']['tmp_name'], or any of the other $_FILE array elements,
doesn't give anything. There is no array of information for the uploaded
file, possibly because of the following problem I'm having:

Another weird thing is that no temporary file is even created on the server
(I did a system search on the C: drive of the windows box I'm using). Here
is the info from my php.ini file:


---


; 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\tmp_uploads

; Maximum allowed size for uploaded files.
upload_max_filesize = 6M




I even changed the upload_tmp_dir setting to the default and it still didn't
create a temporary file of the image on the server. GD is definately
installed and enabled according to phpinfo() -- although GD has nothing to
do with this. I'm uploading *.jpg/*.jpeg files only. register_globals is on
(I am aware of the risks). So what could be wrong? Is there another setting
in the php.ini file that I need to worry about that is not set by default?
I've pondered and tested this long enough and I'm beyond frustration,
someone please help me with some suggestions to get me through this...

Thanks,
- Darwin


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] HTTP POST FILE UPLOAD HELP

2002-11-08 Thread Justin French
Hi,

Simple question first:  There is a perfect working example of file uploads
available on the PHP website in the manual.  Can you get that example to
work?

Justin


on 08/11/02 10:05 PM, @ Darwin ([EMAIL PROTECTED]) wrote:

 
 Ok, I have a problem with my file upload. When I upload a file, say $img,
 only $img is available and when I echo $img to the screen it gives the full
 path of the temporary image supposedly created by PHP. Echoing
 $_FILE['img']['tmp_name'], or any of the other $_FILE array elements,
 doesn't give anything. There is no array of information for the uploaded
 file, possibly because of the following problem I'm having:
 
 Another weird thing is that no temporary file is even created on the server
 (I did a system search on the C: drive of the windows box I'm using). Here
 is the info from my php.ini file:
 
 
 ---
 
 
 ; 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\tmp_uploads
 
 ; Maximum allowed size for uploaded files.
 upload_max_filesize = 6M
 
 
 
 
 I even changed the upload_tmp_dir setting to the default and it still didn't
 create a temporary file of the image on the server. GD is definately
 installed and enabled according to phpinfo() -- although GD has nothing to
 do with this. I'm uploading *.jpg/*.jpeg files only. register_globals is on
 (I am aware of the risks). So what could be wrong? Is there another setting
 in the php.ini file that I need to worry about that is not set by default?
 I've pondered and tested this long enough and I'm beyond frustration,
 someone please help me with some suggestions to get me through this...
 
 Thanks,
 - Darwin
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] HTTP POST FILE UPLOAD HELP

2002-11-08 Thread Ernest E Vogelsinger
At 13:05 08.11.2002,  Darwin spoke out and said:
[snip]
is the info from my php.ini file:


; Temporary directory for HTTP uploaded files (will use system default if
not
; specified).
upload_tmp_dir = C:\PHP\tmp_uploads
[snip] 

I believe you must escape backslashes in php.ini as well... or simply use
forward slashes.

Try this setting:
upload_tmp_dir = C:/PHP/tmp_uploads

Also, if this is Win2K Server, make sure the ACL's are set correctly.
Usually Apache runs as system, so make sure you're giving the system
user full rights (or at least r/w/d) to this directory.


-- 
   O Ernest E. Vogelsinger 
   (\) ICQ #13394035 
^ http://www.vogelsinger.at/



RE: [PHP] HTTP POST FILE UPLOAD HELP

2002-11-08 Thread @ Darwin
You know what, let me try that, and I will get back to you as soon as I can.

- Darwin

 -Original Message-
 From: Justin French [mailto:justin;indent.com.au]
 Sent: Friday, November 08, 2002 7:13 AM
 To: @ Darwin; Php-General
 Subject: Re: [PHP] HTTP POST FILE UPLOAD HELP


 Hi,

 Simple question first:  There is a perfect working example of file uploads
 available on the PHP website in the manual.  Can you get that example to
 work?

 Justin


 on 08/11/02 10:05 PM, @ Darwin ([EMAIL PROTECTED]) wrote:

 
  Ok, I have a problem with my file upload. When I upload a file,
 say $img,
  only $img is available and when I echo $img to the screen it
 gives the full
  path of the temporary image supposedly created by PHP. Echoing
  $_FILE['img']['tmp_name'], or any of the other $_FILE array elements,
  doesn't give anything. There is no array of information for the uploaded
  file, possibly because of the following problem I'm having:
 
  Another weird thing is that no temporary file is even created
 on the server
  (I did a system search on the C: drive of the windows box I'm
 using). Here
  is the info from my php.ini file:
 
 
 --
 --
  ---
 
  
  ; 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\tmp_uploads
 
  ; Maximum allowed size for uploaded files.
  upload_max_filesize = 6M
 
 
 --
 --
  
 
  I even changed the upload_tmp_dir setting to the default and it
 still didn't
  create a temporary file of the image on the server. GD is definately
  installed and enabled according to phpinfo() -- although GD has
 nothing to
  do with this. I'm uploading *.jpg/*.jpeg files only.
 register_globals is on
  (I am aware of the risks). So what could be wrong? Is there
 another setting
  in the php.ini file that I need to worry about that is not set
 by default?
  I've pondered and tested this long enough and I'm beyond frustration,
  someone please help me with some suggestions to get me through this...
 
  Thanks,
  - Darwin
 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] HTTP POST FILE UPLOAD HELP

2002-11-08 Thread @ Darwin
Ok, I'll try that. I never had to do it before, but I'll try it
anyway...I'll get back to you on it...thanks

- Darwin

-Original Message-
From: Ernest E Vogelsinger [mailto:ernest;vogelsinger.at]
Sent: Friday, November 08, 2002 6:22 AM
To:  Darwin
Cc: Php-General
Subject: Re: [PHP] HTTP POST FILE UPLOAD HELP


At 13:05 08.11.2002,  Darwin spoke out and said:
[snip]
is the info from my php.ini file:

---
-
; Temporary directory for HTTP uploaded files (will use system default if
not
; specified).
upload_tmp_dir = C:\PHP\tmp_uploads
[snip]

I believe you must escape backslashes in php.ini as well... or simply use
forward slashes.

Try this setting:
upload_tmp_dir = C:/PHP/tmp_uploads

Also, if this is Win2K Server, make sure the ACL's are set correctly.
Usually Apache runs as system, so make sure you're giving the system
user full rights (or at least r/w/d) to this directory.


--
   O Ernest E. Vogelsinger
   (\) ICQ #13394035
^ http://www.vogelsinger.at/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] HTTP POST FILE UPLOAD HELP

2002-11-08 Thread @ Darwin
Nope, tried that just now. The example doesn't work for me. Any other
suggestions?

- Darwin

 -Original Message-
 From: Justin French [mailto:justin;indent.com.au]
 Sent: Friday, November 08, 2002 7:13 AM
 To: @ Darwin; Php-General
 Subject: Re: [PHP] HTTP POST FILE UPLOAD HELP


 Hi,

 Simple question first:  There is a perfect working example of file uploads
 available on the PHP website in the manual.  Can you get that example to
 work?

 Justin


 on 08/11/02 10:05 PM, @ Darwin ([EMAIL PROTECTED]) wrote:

 
  Ok, I have a problem with my file upload. When I upload a file,
 say $img,
  only $img is available and when I echo $img to the screen it
 gives the full
  path of the temporary image supposedly created by PHP. Echoing
  $_FILE['img']['tmp_name'], or any of the other $_FILE array elements,
  doesn't give anything. There is no array of information for the uploaded
  file, possibly because of the following problem I'm having:
 
  Another weird thing is that no temporary file is even created
 on the server
  (I did a system search on the C: drive of the windows box I'm
 using). Here
  is the info from my php.ini file:
 
 
 --
 --
  ---
 
  
  ; 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\tmp_uploads
 
  ; Maximum allowed size for uploaded files.
  upload_max_filesize = 6M
 
 
 --
 --
  
 
  I even changed the upload_tmp_dir setting to the default and it
 still didn't
  create a temporary file of the image on the server. GD is definately
  installed and enabled according to phpinfo() -- although GD has
 nothing to
  do with this. I'm uploading *.jpg/*.jpeg files only.
 register_globals is on
  (I am aware of the risks). So what could be wrong? Is there
 another setting
  in the php.ini file that I need to worry about that is not set
 by default?
  I've pondered and tested this long enough and I'm beyond frustration,
  someone please help me with some suggestions to get me through this...
 
  Thanks,
  - Darwin
 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] HTTP POST FILE UPLOAD HELP

2002-11-08 Thread Jason Wong
On Saturday 09 November 2002 03:03, [EMAIL PROTECTED] wrote:
 Nope, tried that just now. The example doesn't work for me. Any other
 suggestions?

How doesn't it work? Error messages? Aliens stole your file?

If you can't get the example from the manual to work then you've got serious 
problems :)

Read the whole of the chapter Handling file uploads.

Go over your php.ini settings, quick check that file_uploads is enabled.

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
Illiterate?  Write today, for free help!
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] HTTP POST FILE UPLOAD HELP

2002-11-08 Thread Justin French
Shsh!!  What does Example doesn't work for me mean... to quote Dr
Evil, throw me a friggin' bone here...

HOW doesn't it work... what errors are you getting... what happens... etc
etc.  Make sure you have error reproting set to the highest level too
(E_ALL) I think.


Justin


on 09/11/02 5:03 AM, @ Darwin ([EMAIL PROTECTED]) wrote:

 Nope, tried that just now. The example doesn't work for me. Any other
 suggestions?
 
 - Darwin
 
 -Original Message-
 From: Justin French [mailto:justin;indent.com.au]
 Sent: Friday, November 08, 2002 7:13 AM
 To: @ Darwin; Php-General
 Subject: Re: [PHP] HTTP POST FILE UPLOAD HELP
 
 
 Hi,
 
 Simple question first:  There is a perfect working example of file uploads
 available on the PHP website in the manual.  Can you get that example to
 work?
 
 Justin
 
 
 on 08/11/02 10:05 PM, @ Darwin ([EMAIL PROTECTED]) wrote:
 
 
 Ok, I have a problem with my file upload. When I upload a file,
 say $img,
 only $img is available and when I echo $img to the screen it
 gives the full
 path of the temporary image supposedly created by PHP. Echoing
 $_FILE['img']['tmp_name'], or any of the other $_FILE array elements,
 doesn't give anything. There is no array of information for the uploaded
 file, possibly because of the following problem I'm having:
 
 Another weird thing is that no temporary file is even created
 on the server
 (I did a system search on the C: drive of the windows box I'm
 using). Here
 is the info from my php.ini file:
 
 
 --
 --
 ---
 
 
 ; 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\tmp_uploads
 
 ; Maximum allowed size for uploaded files.
 upload_max_filesize = 6M
 
 
 --
 --
 
 
 I even changed the upload_tmp_dir setting to the default and it
 still didn't
 create a temporary file of the image on the server. GD is definately
 installed and enabled according to phpinfo() -- although GD has
 nothing to
 do with this. I'm uploading *.jpg/*.jpeg files only.
 register_globals is on
 (I am aware of the risks). So what could be wrong? Is there
 another setting
 in the php.ini file that I need to worry about that is not set
 by default?
 I've pondered and tested this long enough and I'm beyond frustration,
 someone please help me with some suggestions to get me through this...
 
 Thanks,
 - Darwin
 
 
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] HTTP POST FILE UPLOAD HELP

2002-11-08 Thread BAROILLER Pierre-Emmanuel
Hi,

how did you make for html form to upload files ?

you need to add an encryption like this to post files...

form name=addFile enctype=multipart/form-data action= method=post 
input type=file name=thefile
/form

If you make a simple post form, you'll never get the posted files! :)
File uploading works with php3  php4 and it's very easy to implement.

cheers.
P.E. Baroiller

@ Darwin [EMAIL PROTECTED] a écrit dans le message de news:
[EMAIL PROTECTED]
 Nope, tried that just now. The example doesn't work for me. Any other
 suggestions?

 - Darwin

  -Original Message-
  From: Justin French [mailto:justin;indent.com.au]
  Sent: Friday, November 08, 2002 7:13 AM
  To: @ Darwin; Php-General
  Subject: Re: [PHP] HTTP POST FILE UPLOAD HELP
 
 
  Hi,
 
  Simple question first:  There is a perfect working example of file
uploads
  available on the PHP website in the manual.  Can you get that example to
  work?
 
  Justin
 
 
  on 08/11/02 10:05 PM, @ Darwin ([EMAIL PROTECTED]) wrote:
 
  
   Ok, I have a problem with my file upload. When I upload a file,
  say $img,
   only $img is available and when I echo $img to the screen it
  gives the full
   path of the temporary image supposedly created by PHP. Echoing
   $_FILE['img']['tmp_name'], or any of the other $_FILE array elements,
   doesn't give anything. There is no array of information for the
uploaded
   file, possibly because of the following problem I'm having:
  
   Another weird thing is that no temporary file is even created
  on the server
   (I did a system search on the C: drive of the windows box I'm
  using). Here
   is the info from my php.ini file:
  
  
  --
  --
   ---
  
   
   ; 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\tmp_uploads
  
   ; Maximum allowed size for uploaded files.
   upload_max_filesize = 6M
  
  
  --
  --
   
  
   I even changed the upload_tmp_dir setting to the default and it
  still didn't
   create a temporary file of the image on the server. GD is definately
   installed and enabled according to phpinfo() -- although GD has
  nothing to
   do with this. I'm uploading *.jpg/*.jpeg files only.
  register_globals is on
   (I am aware of the risks). So what could be wrong? Is there
  another setting
   in the php.ini file that I need to worry about that is not set
  by default?
   I've pondered and tested this long enough and I'm beyond frustration,
   someone please help me with some suggestions to get me through this...
  
   Thanks,
   - Darwin
  
 




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php