Re: [PHP] file upload script
Thanks Philip. I'm now using the code below to upload. What I'm seeing is that the file is uploaded and placed into the /tmp directory but is not being moved to the /PIVOT directory. It just disappears after a few seconds and can't be found in either directory. Any ideas why? Thanks again, Rod - Original Message - From: Philip Olson [EMAIL PROTECTED] To: Rodney Green [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Sunday, June 08, 2003 1:21 AM Subject: Re: [PHP] file upload script By no errors, do you mean you have a PHP version greater than PHP 4.2.0 and checked the ['error'] code, and it has a value of 0? Are you sure you want the filename to be $file_name? I doubt you do. Regards, Philip ref: http://www.php.net/features.file-upload On Sat, 7 Jun 2003, Rodney Green wrote: Hello. I'm attempting to upload a file using the script below and I'm not having any success. The temp directory I'm using does exist and is writeable. When I browse for the file then hit the send button it appears to be working then displays the form again with no errors. I look for the file on the server and it isn't there. Any advice on how to get this working? Thanks! Rod --- html head titleListing 9.14 A file upload script/title /head ?php $file_dir = /home/corrdev/htdocs/php24/scrap/uploads; $file_url = http://corros.colo.hosteurope.com/dev/php24/scrap/uploads;; foreach( $HTTP_POST_FILES as $file_name = $file_array ) { print path: .$file_array['tmp_name'].br\n; print name: .$file_array['name'].br\n; print type: .$file_array['type'].br\n; print size: .$file_array['size'].br\n; if ( is_uploaded_file( $file_array['tmp_name'] ) $file_array['type'] == image/gif ) { move_uploaded_file( $file_array['tmp_name'], $file_dir/$file_name) or die (Couldn't copy); print img src=\$file_url/$file_name\p\n\n; } } ? body form enctype=multipart/form-data method=POST input type=hidden name=MAX_FILE_SIZE value=51200 input type=file name=fuploadbr input type=submit value=Send file! /form /body /html -- 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
Re: [PHP] file upload script
Sorry, here's the code: form name=form1 method=post action= enctype=multipart/form-data input type=file name=imagefile br input type=submit name=Submit value=Submit ?php $filesdir = /PIVOT; echo $_FILES['imagefile']['name']; echo $_FILES['imagefile']['tmp_name']; if(isset( $Submit )) { if ($_FILES['imagefile']['type'] == image/gif) { copy ($_FILES['imagefile']['tmp_name'], $filesdir/.$_FILES['imagefile']['name']) or die (Could not copy); echo brbr; echo Name: .$_FILES['imagefile']['name'].br; echo Size: .$_FILES['imagefile']['size'].br; echo Type: .$_FILES['imagefile']['type'].br; echo Copy Done; } else { echo brbr; echo Could Not Copy, Wrong Filetype (.$_FILES['imagefile']['name'].)br; } } ? /form - Original Message - From: Philip Olson [EMAIL PROTECTED] To: Rodney Green [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Sunday, June 08, 2003 1:21 AM Subject: Re: [PHP] file upload script By no errors, do you mean you have a PHP version greater than PHP 4.2.0 and checked the ['error'] code, and it has a value of 0? Are you sure you want the filename to be $file_name? I doubt you do. Regards, Philip ref: http://www.php.net/features.file-upload On Sat, 7 Jun 2003, Rodney Green wrote: Hello. I'm attempting to upload a file using the script below and I'm not having any success. The temp directory I'm using does exist and is writeable. When I browse for the file then hit the send button it appears to be working then displays the form again with no errors. I look for the file on the server and it isn't there. Any advice on how to get this working? Thanks! Rod --- html head titleListing 9.14 A file upload script/title /head ?php $file_dir = /home/corrdev/htdocs/php24/scrap/uploads; $file_url = http://corros.colo.hosteurope.com/dev/php24/scrap/uploads;; foreach( $HTTP_POST_FILES as $file_name = $file_array ) { print path: .$file_array['tmp_name'].br\n; print name: .$file_array['name'].br\n; print type: .$file_array['type'].br\n; print size: .$file_array['size'].br\n; if ( is_uploaded_file( $file_array['tmp_name'] ) $file_array['type'] == image/gif ) { move_uploaded_file( $file_array['tmp_name'], $file_dir/$file_name) or die (Couldn't copy); print img src=\$file_url/$file_name\p\n\n; } } ? body form enctype=multipart/form-data method=POST input type=hidden name=MAX_FILE_SIZE value=51200 input type=file name=fuploadbr input type=submit value=Send file! /form /body /html -- 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
Re: [PHP] file upload script
What PHP version? You should rewrite your code to more reflect what's being used in the manual. a) use move_uploaded_file() and not copy() b) check what ['error'] has to say c) set action in the form d) print_r($_FILES) is great for debugging e) only show the form is it's not yet submitted, or at least print something only if the form hasn't yet submitted so you know... debug. As for all know, $Submit may never be set. Regards, Philip On Sun, 8 Jun 2003, Rodney Green wrote: Sorry, here's the code: form name=form1 method=post action= enctype=multipart/form-data input type=file name=imagefile br input type=submit name=Submit value=Submit ?php $filesdir = /PIVOT; echo $_FILES['imagefile']['name']; echo $_FILES['imagefile']['tmp_name']; if(isset( $Submit )) { if ($_FILES['imagefile']['type'] == image/gif) { copy ($_FILES['imagefile']['tmp_name'], $filesdir/.$_FILES['imagefile']['name']) or die (Could not copy); echo brbr; echo Name: .$_FILES['imagefile']['name'].br; echo Size: .$_FILES['imagefile']['size'].br; echo Type: .$_FILES['imagefile']['type'].br; echo Copy Done; } else { echo brbr; echo Could Not Copy, Wrong Filetype (.$_FILES['imagefile']['name'].)br; } } ? /form - Original Message - From: Philip Olson [EMAIL PROTECTED] To: Rodney Green [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Sunday, June 08, 2003 1:21 AM Subject: Re: [PHP] file upload script By no errors, do you mean you have a PHP version greater than PHP 4.2.0 and checked the ['error'] code, and it has a value of 0? Are you sure you want the filename to be $file_name? I doubt you do. Regards, Philip ref: http://www.php.net/features.file-upload On Sat, 7 Jun 2003, Rodney Green wrote: Hello. I'm attempting to upload a file using the script below and I'm not having any success. The temp directory I'm using does exist and is writeable. When I browse for the file then hit the send button it appears to be working then displays the form again with no errors. I look for the file on the server and it isn't there. Any advice on how to get this working? Thanks! Rod --- html head titleListing 9.14 A file upload script/title /head ?php $file_dir = /home/corrdev/htdocs/php24/scrap/uploads; $file_url = http://corros.colo.hosteurope.com/dev/php24/scrap/uploads;; foreach( $HTTP_POST_FILES as $file_name = $file_array ) { print path: .$file_array['tmp_name'].br\n; print name: .$file_array['name'].br\n; print type: .$file_array['type'].br\n; print size: .$file_array['size'].br\n; if ( is_uploaded_file( $file_array['tmp_name'] ) $file_array['type'] == image/gif ) { move_uploaded_file( $file_array['tmp_name'], $file_dir/$file_name) or die (Couldn't copy); print img src=\$file_url/$file_name\p\n\n; } } ? body form enctype=multipart/form-data method=POST input type=hidden name=MAX_FILE_SIZE value=51200 input type=file name=fuploadbr input type=submit value=Send file! /form /body /html -- 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] file upload script
Hello. I'm attempting to upload a file using the script below and I'm not having any success. The temp directory I'm using does exist and is writeable. When I browse for the file then hit the send button it appears to be working then displays the form again with no errors. I look for the file on the server and it isn't there. Any advice on how to get this working? Thanks! Rod --- html head titleListing 9.14 A file upload script/title /head ?php $file_dir = /home/corrdev/htdocs/php24/scrap/uploads; $file_url = http://corros.colo.hosteurope.com/dev/php24/scrap/uploads;; foreach( $HTTP_POST_FILES as $file_name = $file_array ) { print path: .$file_array['tmp_name'].br\n; print name: .$file_array['name'].br\n; print type: .$file_array['type'].br\n; print size: .$file_array['size'].br\n; if ( is_uploaded_file( $file_array['tmp_name'] ) $file_array['type'] == image/gif ) { move_uploaded_file( $file_array['tmp_name'], $file_dir/$file_name) or die (Couldn't copy); print img src=\$file_url/$file_name\p\n\n; } } ? body form enctype=multipart/form-data method=POST input type=hidden name=MAX_FILE_SIZE value=51200 input type=file name=fuploadbr input type=submit value=Send file! /form /body /html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file upload script
By no errors, do you mean you have a PHP version greater than PHP 4.2.0 and checked the ['error'] code, and it has a value of 0? Are you sure you want the filename to be $file_name? I doubt you do. Regards, Philip ref: http://www.php.net/features.file-upload On Sat, 7 Jun 2003, Rodney Green wrote: Hello. I'm attempting to upload a file using the script below and I'm not having any success. The temp directory I'm using does exist and is writeable. When I browse for the file then hit the send button it appears to be working then displays the form again with no errors. I look for the file on the server and it isn't there. Any advice on how to get this working? Thanks! Rod --- html head titleListing 9.14 A file upload script/title /head ?php $file_dir = /home/corrdev/htdocs/php24/scrap/uploads; $file_url = http://corros.colo.hosteurope.com/dev/php24/scrap/uploads;; foreach( $HTTP_POST_FILES as $file_name = $file_array ) { print path: .$file_array['tmp_name'].br\n; print name: .$file_array['name'].br\n; print type: .$file_array['type'].br\n; print size: .$file_array['size'].br\n; if ( is_uploaded_file( $file_array['tmp_name'] ) $file_array['type'] == image/gif ) { move_uploaded_file( $file_array['tmp_name'], $file_dir/$file_name) or die (Couldn't copy); print img src=\$file_url/$file_name\p\n\n; } } ? body form enctype=multipart/form-data method=POST input type=hidden name=MAX_FILE_SIZE value=51200 input type=file name=fuploadbr input type=submit value=Send file! /form /body /html -- 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