I have a "Advanced upload widget (Plupload)" as a "file resource" set to an Image field. The whole things works pretty good, except for the tmp directory, where plupload first uploads the files (files are with tmp extension), then renames them, and after copies to proper directory (been set in field settings). The problem is that the source file - in the tmp directory - still exists, it's not removed. Checked in production and at fresh minimal install (7.19) without any additional modules.
I've found this couple lines in plupload.module (lines: 71-79)
$source = $uploaded_file['tmppath'];
$destination = file_stream_wrapper_uri_normalize($scheme . $uploaded_file['name']);
// Rename it to its original name, and put it in its final home.
// Note - not using file_move here because if we call file_get_mime
// (in file_uri_to_object) while it has a .tmp extension, it horks.
$destination = file_unmanaged_move($source, $destination, FILE_EXISTS_RENAME);
$file = plupload_file_uri_to_object($destination);
file_save($file);
$saved_files[] = $file;
and i think there suppose to be same removal instruction in here. When I upload a file using standard drupal functionality (the same field, it has ability to switch), problem not exists.
My first "unsolved drupal problem" and my first issue - be gentle :)
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | filefield_sources_plupload.module.patch | 582 bytes | JacekK |
| #4 | screen01.png | 99.54 KB | JacekK |
Comments
Comment #0.0
JacekK commentedtypo :)
Comment #1
slashrsm commentedHm.... file_unmanaged_move() is used here. Move operation should remove file from tmp location once copied over. Do I understand it right: you have two copies of the same file (tmp and final)?
Comment #2
JacekK commentedYes, I have two files.
I just checked what's happening in every line and I found out, that file_unmanaged_move copies temp file ('tmp' extension, random chars in file name) to it's proper name. Then the custom-object-creator returns an object with a "filename" property. I assume the file_save takes the filename and probably search for it in the "temporary://" directory and saves it by the "destination" property (which has "public://" in the beginning). I'll try to dig more, if I find some time.
Additionally, what is the $saved_files array for? It's neither returned, nor used.
Comment #3
slashrsm commentedI tried to reproduce this using Plupload, File entity 7.x-2.x and Media 7.x-2.x and I was unable to reproduce the issue. Temporary files are removed after upload. Can you double-check that there is no problem with filesystem permissions or the module that implements Plupload.
Where exactly is this?
Comment #4
JacekK commentedI'm not using File entity nor Media, just File Field Sources, FileField Sources Plupload and Plupload integration module.
Today I've played around with fresh Debian installation, I've installed apache, started using drush :) ... and the result is like in the png file below this comment. "test--1.png" was uploaded normally, "test--2.png" through the plupload plugin, and it stayed in the "tmp" directory. I've tested that also at Win7/wamp, and two linux servers with unknown config (the second has some directory-level permissions problem when creating folders, but never with files).
There is a common thing in all, I always put the "tmp" directory in the main directory ... could this be a problem? Should I use the OS'es temp directory?
The plupload library was downloaded from here: http://www.plupload.com/download.php - there's version 1.5.6, but version 1.5.4 acts the same.
Like I wrote in the first post, file "plupload.module", lines 71-79.
Comment #5
slashrsm commentedFunction function plupload_test_submit() (line 63-86) is there for testing reasons and it is not called in your environment.
Temp folder can be anywhere you want. It is probably good if it is out of web-root, though.
It looks like this issue belongs to FileField Sources Plupload.
Comment #6
JacekK commentedI finally found some time to dig in and I've just figured this out. The attached patch should work. I'd be glad to apply this in near future :)
Comment #7
atlea commentedThis is now fixed in dev. Thanks. :)
Comment #8.0
(not verified) commentedmore typos :]