Re: [PHP] upload file problem
On Thu, Jul 31, 2008 at 10:18 AM, Jignesh Thummar [EMAIL PROTECTED] wrote: I'm trying to upload the file. It's showing me successfully uploaded. But it's not able to move from temp directory to my defined directory my code: if (is_uploaded_file($_FILES['myfile']['tmp_name'])) { move_uploaded_file($_FILES['myfile']['tmp_name'], $myfilename); echo File . $_FILES['myfile']['name'] . uploaded successfully.\n; } else { echo File uploading error; } Thanks in advance. -Jignesh Is the directory you're moving to writable by your web server? If you don't know, try making a separate script that tries var_dump(is_writable('/path/to/uploads')); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] upload file problem
it's writable. On Thu, Jul 31, 2008 at 3:37 PM, Eric Butera [EMAIL PROTECTED] wrote: On Thu, Jul 31, 2008 at 10:18 AM, Jignesh Thummar [EMAIL PROTECTED] wrote: I'm trying to upload the file. It's showing me successfully uploaded. But it's not able to move from temp directory to my defined directory my code: if (is_uploaded_file($_FILES['myfile']['tmp_name'])) { move_uploaded_file($_FILES['myfile']['tmp_name'], $myfilename); echo File . $_FILES['myfile']['name'] . uploaded successfully.\n; } else { echo File uploading error; } Thanks in advance. -Jignesh Is the directory you're moving to writable by your web server? If you don't know, try making a separate script that tries var_dump(is_writable('/path/to/uploads')); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] upload file problem
Maybe check the return value of the function: http://us3.php.net/manual/en/function.move-uploaded-file.php Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Jignesh Thummar wrote: I'm trying to upload the file. It's showing me successfully uploaded. But it's not able to move from temp directory to my defined directory my code: if (is_uploaded_file($_FILES['myfile']['tmp_name'])) { move_uploaded_file($_FILES['myfile']['tmp_name'], $myfilename); echo File . $_FILES['myfile']['name'] . uploaded successfully.\n; } else { echo File uploading error; } Thanks in advance. -Jignesh -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] upload file problem
On Thu, Jul 31, 2008 at 10:18 AM, Jignesh Thummar [EMAIL PROTECTED] wrote: I'm trying to upload the file. It's showing me successfully uploaded. But it's not able to move from temp directory to my defined directory my code: if (is_uploaded_file($_FILES['myfile']['tmp_name'])) { move_uploaded_file($_FILES['myfile']['tmp_name'], $myfilename); echo File . $_FILES['myfile']['name'] . uploaded successfully.\n; } else { echo File uploading error; } If it is passing the if(is_uploaded_file()) condition, echo out $myfilename and make sure it's valid to use as a path/filename. -- /Daniel P. Brown Better prices on dedicated servers: Intel 2.4GHz/60GB/512MB/2TB $49.99/mo. Intel 3.06GHz/80GB/1GB/2TB $59.99/mo. Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] upload file problem
Jignesh Thummar wrote: I'm trying to upload the file. It's showing me successfully uploaded. But it's not able to move from temp directory to my defined directory my code: if (is_uploaded_file($_FILES['myfile']['tmp_name'])) { move_uploaded_file($_FILES['myfile']['tmp_name'], $myfilename); echo File . $_FILES['myfile']['name'] . uploaded successfully.\n; } else { echo File uploading error; } What does $myfilename resolve to? It should include the complete path from server root (not DOCUMENT_ROOT). Try: echo File uploading error: ${myfilename}; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] upload file problem
Thanks.. It's fixed... - Jignesh On Thu, Jul 31, 2008 at 6:05 PM, brian [EMAIL PROTECTED] wrote: Jignesh Thummar wrote: I'm trying to upload the file. It's showing me successfully uploaded. But it's not able to move from temp directory to my defined directory my code: if (is_uploaded_file($_FILES['myfile']['tmp_name'])) { move_uploaded_file($_FILES['myfile']['tmp_name'], $myfilename); echo File . $_FILES['myfile']['name'] . uploaded successfully.\n; } else { echo File uploading error; } What does $myfilename resolve to? It should include the complete path from server root (not DOCUMENT_ROOT). Try: echo File uploading error: ${myfilename}; -- 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] upload file problem
On Sat, July 9, 2005 1:39 am, Ahmed Abdel-Aliem said: Hi i have a problem with a code to upload files on server here is the code $f = $HTTP_POST_FILES['News_Pic']; Use $_FILES to stay current... $dst_file_name = generateUniqueId(); $arr = split(\.,$f['name']); $f['name'] = $dst_file_name; $f['name'] .= ..$arr[count($arr)-1]; $dest_dir = 'main/pictures'; $dest = $dest_dir . '/' .$f['name']; So, what happened to $dst_file_name? Far as I can tell, you've never used it... $r = move_uploaded_file($f['tmp_name'], $dest); $News_Pic = $f['name']; chmod($dest, 777); Nooo! You should *NOT* be trying to make the files 777. And it should be 0777 anyway. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Upload File Problem
From: Mark Colvin [mailto:[EMAIL PROTECTED]] Sent: Thursday, July 18, 2002 10:09 AM -- upload.php -- ?php if ('img1' != ) { This will allways be true! 'img1' is a string and will never be empty. You probably mean if($img1 != ) However, I'm not sure this will work in this case. Try this instead. (Taken straight from the PHP-manual. A real good resource!) ?php if (is_uploaded_file($_FILES['img1']['tmp_name'])) { $filename = $_FILES['img1']['tmp_name']; print $filename was uploaded successfuly; $realname = $_FILES['img1']['name']; print realname is $realname; print copying file to uploads dir; copy($_FILES['img1']['tmp_name'], /place/to/put/ . $realname); } else { echo Possible file upload attack: filename . $_FILES['img1']['name'] . .; } ? If you use PHP 4.1.0 you must exchange $_FILES to $HTTP_POST_FILES Regards Joakim Andersson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Upload File Problem
Joakim, Thank you for your reply. I tried your example and get 'Possible file upload attack: filename.' meaning that 'if (is_uploaded_file($_FILES['img1']['tmp_name']))' returns false. I put a couple of echo statements in before the if statement to check '$img1_name' '$img1_size and '$img1_type' and these all returned the correct values. I have my upload_tmp_dir in php.ini set to /var/www/html/img and this folder has 777 permissions. Do you think the file is not getting to temp directory and if so any idea why? This e-mail is intended for the recipient only and may contain confidential information. If you are not the intended recipient then you should reply to the sender and take no further ation based upon the content of the message. Internet e-mails are not necessarily secure and CCM Limited does not accept any responsibility for changes made to this message. Although checks have been made to ensure this message and any attchments are free from viruses the recipient should ensure that this is the case. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Upload File Problem
From: Mark Colvin [mailto:[EMAIL PROTECTED]] Sent: Thursday, July 18, 2002 12:41 PM To: [EMAIL PROTECTED] Joakim, Thank you for your reply. I tried your example and get 'Possible file upload attack: filename.' meaning that 'if (is_uploaded_file($_FILES['img1']['tmp_name']))' returns false. I put a couple of echo statements in before the if statement to check '$img1_name' '$img1_size and '$img1_type' and these all returned the correct values. I have my upload_tmp_dir in php.ini set to /var/www/html/img and this folder has 777 permissions. Do you think the file is not getting to temp directory and if so any idea why? Have you tried echoing $_FILES['img1']['tmp_name'] or $HTTP_POST_FILES['img1']['tmp_name']? If the first doesn't work, you may have to exchange $_FILES to $HTTP_POST_FILES or $_FILES['img1']['tmp_name'] to $img1_tmp_name etc. /Joakim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Upload File Problem
Joakim, Thanks again. $HTTP_POST did the trick. I did look through the archives before posting but didn't come across this solution. I obviously didn't look hard enough! This e-mail is intended for the recipient only and may contain confidential information. If you are not the intended recipient then you should reply to the sender and take no further ation based upon the content of the message. Internet e-mails are not necessarily secure and CCM Limited does not accept any responsibility for changes made to this message. Although checks have been made to ensure this message and any attchments are free from viruses the recipient should ensure that this is the case. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php