Re: Chapter 38. Handling file uploads
| From: | Jason Barnett | Date: | Fri, 18 Mar 2005 22:26:10 +0000 |
| Subject: | Re: Chapter 38. Handling file uploads | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-211076@lists.php.net to get a copy of this message | ||
Timothy A. Whitley wrote:
> I am using the code at the top of this chapter to upload a file and move
> to a given destination directory. I get the following error messages and
> my file is not to be found. The only thing I am changing is where I want
> the file to be stored.
>
> Thanks.
>
> Warning: move_uploaded_file(/images/tim.jpg): failed to open stream: No
> such file or directory in
Do you have the folder /images ? Does the PHP user have write access to
this directory? PHP *might* also need X-ecute permissions on the directory.
> /usr/hsphere/local/home/ice-admi/iceagents.com/CxDatabase/fileuploadh.ph
> p on line 20
>
>
>
> Warning: move_uploaded_file(): Unable to move '/var/tmp/phpcrIqVo' to
> '/images/tim.jpg' in
> /usr/hsphere/local/home/ice-admi/iceagents.com/CxDatabase/fileuploadh.ph
> p on line 20
>
Does the PHP user have read / write access to the folder /var/tmp ?
>
> Possible file upload attack!
> Here is some more debugging info:Array
> (
> [userfile] => Array
> (
> [name] => tim.jpg
> [type] => image/pjpeg
> [tmp_name] => /var/tmp/phpcrIqVo
> [error] => 0
> [size] => 17024
> )
>
> )
Seems that the temp file was created ok because you have error code 0.
So the problem appears to be related to moving / writing the file to
/images/tim.jpg. Couple of possibilities off the top of my head:
- insufficient permissions (ls -l)
- open_basedir in php.ini (are you using it?)
- safe_mode in php.ini (are you using it?)
- /images is relative, but not in your include_path. If this is the
problem then using an absolute path should work.
--
Teach a man to fish...
NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc