Hi All,

First off, my provider upgraded to PHP5 and I don't have a choice about this. It broke a few things, most of which I've been able to fix, but not this problem. I understand the problem lies with PHP5's implementation of realpath(). And the fix involves adding dirname()inside the call to realpath(). I've been working on includes/file.inc. I've improved functionality to the point where

  1. files are written to the /tmp directory
  2. files can be previewed before posting
  3. files are moved from /tmp directory to base directory
  4. db table files is updated with filepath=./filename

I've put some reporter error messages in so I can see what's happening.
Here's what it looks like:

On file attachment

  1. call file_create_path 10 times in a row with $dest=0
  2. call file_move where $dest='tmp'
  3. call file_copy, $dest=tmp, filepath='newfiles' //this is correct
  4. call file check directory
  5. call file_create_path 2 more times

On Submit

  1. call file_create_path 11x
  2. call file_move where $dest='filename'
  3. call file_copy, $dest='filename and filepath='newfiles' //this is correct
  4. call file_create_path 10 times in a row with $dest=0

End result

I have to manually copy uploaded files from base directory to ./newfiles/ After that all links work.

Questions

  • Why is the newfiles directory not put in the db.files.filepath?
  • Why is the file moved from ./tmp to ./ instead of to ./newfiles?
  • Why are the links correct (e.g. www.mysite.com/Drupal_home/newfiles/filename) when the db and file location are wrong?
  • How can I fix this?

I greatly appreciate any thoughts you might have on this. I know Drupal and PHP5 don't get along well yet, but this is what I'm stuck with.

Cheers,
Jennifer

Comments

radiofranky’s picture

i'm having a similar problem. file attachement doesn't work.

it gets moved into the tmp folder but not to the final folder.
this is the error message i'm getting

Message move_uploaded_file(): Moved: '/var/tmp/phpL7vK6F' to 'files/tmp/tmp_ZlaKpb' in /home/recipesh/public_html/beta/includes/file.inc on line 239.
Severity error

drupal: 4.71

elgreg’s picture

I banged my head against the wall on this for two days... I would upload files and they just wouldn't stick. I could see them uploading to the tmp directory, but they never appeared in the files directory. This meant they also weren't processed by imagecache, etc. I thought it was file permissions or imagecache or imageapi or imagefield or .htaccess and everything else under the sun. It worked locally on my dev server and on Site5, but not on another host (the production one, of course). I re-uploaded every file. I upgraded all modules. Everything.

Eventually, I went against the warning in the Site Configuration->File System page and changed my files directory to "files2" (or whatever). I tried another upload and voila. It works again... granted, I'm going to have to reupload all the images... but at least it works.