[PHP] Upload problem - final size is different
Hi, I have a form to upload file on my web server, so user can upload their images. The upload work. The user file is uploaded to my destination folder (page5/) but the file is unreadable and the file size is smaller than the original file size. I run Apache with PHP 4.1.2. Thank you, Eric. Here is the form code: method="post"> Une image Du texte: Here is my PHP upload code: "; $tmp_name = $_FILES['uneimage']['tmp_name']; $type = $_FILES['uneimage']['type']; $name = $_FILES['uneimage']['name']; $size = $_FILES['uneimage']['size']; echo $tmp_name . "" . $type . "" . $name . ""; $target_path = "page5/"; $target_path = $target_path . basename( $_FILES['uneimage']['name']); echo $target_path; if(move_uploaded_file($_FILES['uneimage']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uneimage']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Upload problem - final size is different
$error = $_FILES['uneimage']['error']; That doesn't seem work in PHP 4.1.2... I try it but $error is empty. And the function move_uploaded_file($_FILES['uneimage']['tmp_name'], $target_path) returns TRUE, so the upload work (in a way !). The problem is the file that is upload doesn't match the original file. Eric. Le 2007-05-08 à 14:04, Richard Lynch a écrit : On Tue, May 8, 2007 11:30 am, Eric Trahan wrote: The upload work. The user file is uploaded to my destination folder (page5/) but the file is unreadable and the file size is smaller than the original file size. $tmp_name = $_FILES['uneimage']['tmp_name']; $type = $_FILES['uneimage']['type']; $name = $_FILES['uneimage']['name']; $size = $_FILES['uneimage']['size']; $error = $_FILES['uneimage']['error']; switch($error){ //There are at least 5 or 6 'case' statements that go here //read the manual to find them } -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Upload problem - final size is different
Le 2007-05-08 à 16:50, Richard Davey a écrit : By how much is the difference? Are we talking a few bytes, a few megabytes, what? A 116Kb file produce a 68Kb file on the server. And a 152Kb file produce a 48Kb file on the server... If you then download the file again, is it corrupted, or does it work? Download the same file twice produce the same problem... Eric -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Upload problem - final size is different
After some other tests, I think the problem is with the rights of the file. I made tests on my personnal Mac that runs Apache/1.3.33 (Darwin) PHP/ 4.4.4. Settings in PHP: file_uploads: On upload_tmp_dir: no value (so it uploads in /var/tmp/) upload_max_filesize: 2M My destination folder is page5, same as my server (everyone can read and write). But when the files are droped in that folder, with the move_uploaded_file function, the owner is www and group is wheel. So I can't open it... But when I change the rights on the file, I can the see the images. Is there a way to change the owner or the group of a file in PHP. Eric Le 2007-05-08 à 17:52, itoctopus a écrit : Have you tried your code on another server? -- itoctopus - http://www.itoctopus.com "Eric Trahan" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hi, I have a form to upload file on my web server, so user can upload their images. The upload work. The user file is uploaded to my destination folder (page5/) but the file is unreadable and the file size is smaller than the original file size. I run Apache with PHP 4.1.2. Thank you, Eric. Here is the form code: Une image Du texte: Here is my PHP upload code: "; $tmp_name = $_FILES['uneimage']['tmp_name']; $type = $_FILES['uneimage']['type']; $name = $_FILES['uneimage']['name']; $size = $_FILES['uneimage']['size']; echo $tmp_name . "" . $type . "" . $name . ""; $target_path = "page5/"; $target_path = $target_path . basename( $_FILES['uneimage']['name']); echo $target_path; if(move_uploaded_file($_FILES['uneimage']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uneimage']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } ?> -- 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] Re: Upload problem - final size is different
Thank you all for your tips and solutions !! I use chmod and my upload form works fine ;) Eric Le 2007-05-09 à 10:23, Daniel Brown a écrit : PHP has two functions that may help you here, Eric --- chmod() and chown(). http://php.net/chmod http://php.net/chown It should be enough to chmod($filename,0644); the file if it's just an image, or chmod($filename,0755); the file if it's a script. On 5/9/07, Eric Trahan <[EMAIL PROTECTED]> wrote: After some other tests, I think the problem is with the rights of the file. I made tests on my personnal Mac that runs Apache/1.3.33 (Darwin) PHP/ 4.4.4. Settings in PHP: file_uploads: On upload_tmp_dir: no value (so it uploads in /var/tmp/) upload_max_filesize: 2M My destination folder is page5, same as my server (everyone can read and write). But when the files are droped in that folder, with the move_uploaded_file function, the owner is www and group is wheel. So I can't open it... But when I change the rights on the file, I can the see the images. Is there a way to change the owner or the group of a file in PHP. Eric Le 2007-05-08 à 17:52, itoctopus a écrit : > Have you tried your code on another server? > > -- > itoctopus - http://www.itoctopus.com > "Eric Trahan" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> Hi, >> >> I have a form to upload file on my web server, so user can upload >> their >> images. >> >> The upload work. The user file is uploaded to my destination folder >> (page5/) but the file is unreadable and the file size is smaller >> than the >> original file size. >> >> I run Apache with PHP 4.1.2. >> >> Thank you, >> >> Eric. >> >> >> Here is the form code: >> >> > method="post"> >> >> Une image >> Du texte: >> >> >> >> >> Here is my PHP upload code: >> >> > >> echo $_POST['untexte'] . ""; >> >> $tmp_name = $_FILES['uneimage']['tmp_name']; >> $type = $_FILES['uneimage']['type']; >> $name = $_FILES['uneimage']['name']; >> $size = $_FILES['uneimage']['size']; >> >> echo $tmp_name . "" . $type . "" . $name . ""; >> >> $target_path = "page5/"; >> >> $target_path = $target_path . basename( $_FILES['uneimage'] ['name']); >> >> echo $target_path; >> >> if(move_uploaded_file($_FILES['uneimage']['tmp_name'], >> $target_path)) { >> echo "The file ". basename( $_FILES['uneimage']['name']). >> " has been uploaded"; >> } else{ >> echo "There was an error uploading the file, please try again!"; >> } >> ?> > > -- > 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 -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php