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
Re: [PHP] Re: Upload problem - final size is different
I was thinking the same thing, Richard, but didn't say anything because of my limited experience with MacOS. I know it's built on BSD, but to be honest, I have no clue what may have changed over the years. On 5/9/07, Richard Lynch <[EMAIL PROTECTED]> wrote: On Wed, May 9, 2007 9:15 am, Eric Trahan 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. There probably is a http://php.net/chown, but unless you are running Apache as 'root' (DON'T DO THAT!) then it won't work. However, you can use http://php.net/chmod to make the file readable by you as well as the 'www' user. It is very frightening, however, to see the group 'wheel' on the file, since 'wheel' is usually reserved for users that can 'su' to root, and having uploaded image files in that group just doesn't feel right. -- 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 -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107
Re: [PHP] Re: Upload problem - final size is different
On Wed, May 9, 2007 9:15 am, Eric Trahan 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. There probably is a http://php.net/chown, but unless you are running Apache as 'root' (DON'T DO THAT!) then it won't work. However, you can use http://php.net/chmod to make the file readable by you as well as the 'www' user. It is very frightening, however, to see the group 'wheel' on the file, since 'wheel' is usually reserved for users that can 'su' to root, and having uploaded image files in that group just doesn't feel right. -- 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] Re: Upload problem - final size is different
Eric Trahan wrote: Is there a way to change the owner or the group of a file in PHP. http://uk2.php.net/chown But remember the chown will fail if the user Apache is running under does not have sufficient rights to perform the task. Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk "Never trust a computer you can't throw out of a window" -- 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
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
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
Eric, If you're checking the filesize via FTP, a web-based file manager, or even the shell if it's a cross-platform upload, it can give bad data. Try downloading the file and seeing if it's still working. If it does, try uploading it via FTP and having a script check the md5 hash on the two files while still on the server. Other possibilities could include: * Settings in php.ini for upload_max_filesize or max_execution_time, max_input_time, or memory_limit, among others. * Out of disk space on the partition you're saving to, or the /tmp partition (or wherever PHP is set to write to). * A trojan horse or virus on the server side that may be infecting the files upon upload. On 5/8/07, itoctopus <[EMAIL PROTECTED]> wrote: 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 -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107
[PHP] Re: Upload problem - final size is different
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] Re: Upload problem
Have you tried to change the defualt timeout value from 30 secs to something larger or even -1 in the php.ini file? Could be a problem to upload 4mb in 30 secs if your on a slow conn.. /Micke "FyiÎ?rk µérkt" <[EMAIL PROTECTED]> skrev i meddelandet 004001c1e12d$43ca16a0$020296c2@actarus">news:004001c1e12d$43ca16a0$020296c2@actarus... > Hi All, it's my first post here. > > I've got a problem with the upload. I want to upload a 4Mo file on the > server but it refuses to work. I modified the max_upload_size in the php.ini > but it continues to refuse the transfer. If I upload a smaller file it works > fine. > > Someone told me to modify the MAX_FILE_SIZE constant but I don't find it. > > I need help, Thanks > > Fred from Paris > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php