When you move the uploaded file using file_save_upload(), subsequent calls to file_check_upload() will report the old location of the file.

Steps to produce:

  • $file1 = file_check_upload('my_file_field') -- now the function static cache is updated
  • file_save_upload($file1) -- $file1 is: 1. moved to tempdir, 2. updated to reflect the new filepath. 3. stored in $_SESSION['file_uploads']['my_file_field']
  • $file1 = file_check_upload('my_file_field') -- this will hit the static cache instead of usign $_SESSION and thus, will return the old $file1 with the wrong filepath.

I'm not sure if this is by design or has to solved. Myself, I banged head for hours because of this.

Comments

AmrMostafa’s picture

Status: Active » Closed (fixed)

No longer applies, File API was largely reworked and file_check_upload doesn't exist now.