file not uploaded to the wanted location

See all posts See thread Reply

Re: file not uploaded to the wanted location new!
by Tom Benjamin, 18 years ago
Sorry, Colin, I still get the same result:

file not uploaded to the wanted location
Error: No source file. Can't carry on a process


source is an uploaded file
- upload OK
- file name OK
- source variables
    file_src_name         : dondale_benjamin.pdf
    file_src_name_body    : dondale_benjamin
    file_src_name_ext     : pdf
    file_src_pathname     : /data/temp/phpvYxNaw
    file_src_mime         : application/pdf
    file_src_size         : 64278 (max= 134217728)
    file_src_error        : 0
process file to /data/in/b/beverley/www/select/locations/test/
- file size OK
- file mime OK : application/pdf
- file name safe format
- destination variables
    file_dst_path         : /data/in/b/beverley/www/select/locations/test/
    file_dst_name_body    : dondale_benjamin
    file_dst_name_ext     : pdf
- image operation, keep extension
- checking for auto_rename
- destination file details
    file_dst_name         : dondale_benjamin.pdf
    file_dst_pathname     : /data/in/b/beverley/www/select/locations/test/dondale_benjamin.pdf
- dondale_benjamin.pdf doesn't exist already

My ISP technical support replied with the following:
"I would have to see the source code to be sure of course but from your description it sounds like are not following the correct procedure for dealing with uploaded files".

"The key thing to keep in mind that is that you need to move the upload to a local directory in your account (which you have given the web server "rwx" access to) first before manipulating it. You cannot directly access files outside of your account which is why the function "move_uploaded_file" exists".

"This issue is actually handled quite well in the official PHP documentation ..."

I'd appreciate any help you can offer.

Thanks,

TomReply
Re: file not uploaded to the wanted location new!
by colin, 18 years ago
What your hosting company says is right, however you can still read the file from the temp directory, or so I believe. I understand the problem that you have, but I never experienced it. I heard that the same behaviour occurs in a chroot situation.

The code which makes problem is the following:
if ($this->processed && !file_exists($this->file_src_pathname)) {
  $this->processed = false;
  $this->error = _("No source file. Can't carry on a process");
}

As far as I know, that code should be OK, since you should be able to have PHP to check if the file exists, before you copy it (even with move_uploaded_file()). I will do some checks tonight if I get a bit of time.

Otherwise, the solution would be to modify the class so that the uplaoded file is first copied in a temporary directory on which you have full access. I meant to do that for the chroot people anyway, but it's a fairly big change, and also you need to set up a temp directory. This is annoying since most problem will not actually need it.

I will see, and get back to you.Reply