Re: [PHP] Upload dir
2009/12/11 Ashley Sheridan a...@ashleysheridan.co.uk On Fri, 2009-12-11 at 15:44 +, Richard Quadling wrote: 2009/12/11 kranthi kranthi...@gmail.com: How can i change the temporary upload directory? var_dump(ini_get('upload_tmp_dir')); gives me (and that is set in php.ini) string '/var/www/cgi-bin' (length=16) but var_dump($_FILES) gives me 'tmp_name' = string '/tmp/phpbSZ6WP' (length=14) var_dump(file_exists($_FILES['file']['tmp_name'])); gives me (/tmp has permissions drwxrwxrwt and i never used file_move_upload or any similar functions) boolean false am I missing something here? Kranthi. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Just assuming you could alter the upload_tmp_dir setting in your code (you can't) ... PHP puts the uploaded files into the upload_tmp_dir BEFORE your script runs, so changing it in your script essentially hides the uploaded files. PHP drops the files into directory A. PHP then runs your code. Your code changes the directory to B. Your code cannot see the files PHP put into A as your code is now looking in B. But, as I said earlier, you can't use your code to change upload_tmp_dir. It can only be done at the system level (php.ini or httpd.conf). See [1] and [2]. Regards, Richard Quadling. [1] http://docs.php.net/manual/en/ini.core.php#ini.sect.file-uploads [2] http://docs.php.net/manual/en/configuration.changes.modes.php -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling The only reason I can see for wanting to do this would be where several sites exist on the same server and you might want each site to have its own temporary upload directory. It won't have any bearing on how you handle the uploads unless it becomes full. Thanks, Ash http://www.ashleysheridan.co.uk Another way to handle this is via php.ini sections [1] Regards, Richard. [1] http://docs.php.net/manual/en/ini.sections.php -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Upload dir
my mistake didn't use move_uploaded_file to see if the uploading is working or not in the first case but i could not understand why 1. ini_get() is giving correct value while $_FILES['file']['tmp_name'] is ignoring that. 2. move_uploaded_file($_FILES['file']['tmp_name'], 'file.php'); is working fine but file_exists($_FILES['file']['tmp_name']) is returning false 3. php_admin_value upload_tmp_dir /var/www/html in httpd.conf seems to work ($_FILES['file']['tmp_name'] is not ignoring that); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Upload dir
2009/12/11 kranthi kranthi...@gmail.com: How can i change the temporary upload directory? var_dump(ini_get('upload_tmp_dir')); gives me (and that is set in php.ini) string '/var/www/cgi-bin' (length=16) but var_dump($_FILES) gives me 'tmp_name' = string '/tmp/phpbSZ6WP' (length=14) var_dump(file_exists($_FILES['file']['tmp_name'])); gives me (/tmp has permissions drwxrwxrwt and i never used file_move_upload or any similar functions) boolean false am I missing something here? Kranthi. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Just assuming you could alter the upload_tmp_dir setting in your code (you can't) ... PHP puts the uploaded files into the upload_tmp_dir BEFORE your script runs, so changing it in your script essentially hides the uploaded files. PHP drops the files into directory A. PHP then runs your code. Your code changes the directory to B. Your code cannot see the files PHP put into A as your code is now looking in B. But, as I said earlier, you can't use your code to change upload_tmp_dir. It can only be done at the system level (php.ini or httpd.conf). See [1] and [2]. Regards, Richard Quadling. [1] http://docs.php.net/manual/en/ini.core.php#ini.sect.file-uploads [2] http://docs.php.net/manual/en/configuration.changes.modes.php -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Upload dir
On Fri, 2009-12-11 at 15:44 +, Richard Quadling wrote: 2009/12/11 kranthi kranthi...@gmail.com: How can i change the temporary upload directory? var_dump(ini_get('upload_tmp_dir')); gives me (and that is set in php.ini) string '/var/www/cgi-bin' (length=16) but var_dump($_FILES) gives me 'tmp_name' = string '/tmp/phpbSZ6WP' (length=14) var_dump(file_exists($_FILES['file']['tmp_name'])); gives me (/tmp has permissions drwxrwxrwt and i never used file_move_upload or any similar functions) boolean false am I missing something here? Kranthi. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Just assuming you could alter the upload_tmp_dir setting in your code (you can't) ... PHP puts the uploaded files into the upload_tmp_dir BEFORE your script runs, so changing it in your script essentially hides the uploaded files. PHP drops the files into directory A. PHP then runs your code. Your code changes the directory to B. Your code cannot see the files PHP put into A as your code is now looking in B. But, as I said earlier, you can't use your code to change upload_tmp_dir. It can only be done at the system level (php.ini or httpd.conf). See [1] and [2]. Regards, Richard Quadling. [1] http://docs.php.net/manual/en/ini.core.php#ini.sect.file-uploads [2] http://docs.php.net/manual/en/configuration.changes.modes.php -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling The only reason I can see for wanting to do this would be where several sites exist on the same server and you might want each site to have its own temporary upload directory. It won't have any bearing on how you handle the uploads unless it becomes full. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Upload dir
OK you used ini_get try using ini_set and set the temporary directory on your server of your choice at run time in your script (top of the script or any config file if you have one). REMEMBER that you have access to that directory, should have full permissions and also check the absolute server path is correct while you set the directory. More information on how to use ini_set to set the directory path- try googling... Gaurav Kumar blog.oswebstudio.com On Fri, Dec 11, 2009 at 10:59 AM, kranthi kranthi...@gmail.com wrote: How can i change the temporary upload directory? var_dump(ini_get('upload_tmp_dir')); gives me (and that is set in php.ini) string '/var/www/cgi-bin' (length=16) but var_dump($_FILES) gives me 'tmp_name' = string '/tmp/phpbSZ6WP' (length=14) var_dump(file_exists($_FILES['file']['tmp_name'])); gives me (/tmp has permissions drwxrwxrwt and i never used file_move_upload or any similar functions) boolean false am I missing something here? Kranthi. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Upload dir
i doubt i can use ini_set in this scenario http://us3.php.net/manual/en/ini.core.php#ini.upload-tmp-dir -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php