Hi, Need help with the following error which is preventing me from installing modules.

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to access temporary://bandcamp-7.x-0.1.tar.gz in file_save_upload() (line 1528 of /f5/stealingaxion/public/includes/file.inc).

File upload error. Could not move uploaded file.

Comments

Antwanvdm’s picture

Sounds like a CMOD error.. Did you check with FTP (through FileZilla for example) if the folders you want to perform actions on are set to 777?

bhosmer’s picture

Or, you may have not set a directory in your file system settings that is reachable by drupal: admin>settings>file system

Set a temporary path that is writable by trouble, but outside your document root.

You may want to also make sure your file system is set to public on that same page, unless you have a reason for making a private file system.

leelouch’s picture

Hi, while trying to modify logo, I have same issue,
my temp directory in file system configuration is set to sites/default/files/tmp directory
I have no permissions issues , everything is under full permissions (777) (sites to tmp dir),
and I have this error !
Warning : move_uploaded_file() [function.move-uploaded-file]: Unable to access temporary://logo.jpg dans file_save_upload() (ligne 1528 dans /home/xxxxxx/includes/file.inc).
any help please ...

ribakker’s picture

Assuming you are working on a LAMP server, try changing the location of you temp directory into '/tmp'.

leelouch’s picture

The /tmp access is limited by the provider ! it's mandatory to set a new tmp in filesystem (sites/default/files/tmp)
the probleme seems to be the access to "tempory://"
I take a look to the code : the move_uploaded_file(source, destination) take as destination the string "tempory://logo.jpg" !! and not /home/xxx/sites/default/files/tmp/logo.jpg
is this normal ?!
is it a bug ?

bhosmer’s picture

You need to set it to a folder that you can access. Try creating a folder in your drupal root then, call it tmp or anything you want really. Then add that path to your settings and it should work.

leelouch’s picture

let me explain
in file system configuration, I set Public file system path to : public : created by ftp client and chmod to 777
private file system path : empty
temporary directpry : tmp : created by ftp client and chmod to 777

and still have same problem !!
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to access temporary://logo.jpg in file_save_upload() (line 1528 of /home/xxxxx/includes/file.inc).
File upload error. Could not move uploaded file.

leelouch’s picture

I fix that by replacing in line 1528 in includes/file.inc

if (!move_uploaded_file($_FILES['files']['tmp_name'][$source], $file->uri)) {
by
if (!move_uploaded_file($_FILES['files']['tmp_name'][$source], drupal_realpath($file->uri))) {

It's more logical for me ! and it's working !

Aso2’s picture

Thanks a lot leelouch. Fixed.

lrmontero’s picture

it really help me

iandickson’s picture

Best case - you have to keep fixing every time you upgrade.

Worst cose - knock on effects.

I had the same issue on a clean install for a new site. Out of curiosity I tried this fix and it worked, HOWEVER a better fix (no code change) was to turn Php Safe Mode OFF at my host.

joeforika’s picture

I had the same issue with a fresh Drupal 7 installation. After turning off the Php Safe Mode on my VPS , it fixed the problem immediately.

supawebs’s picture

Thank you leelouch. Have spent hours trying to fix this

Ionut Adrian Luchian’s picture

Many thanks to leelouch.

hoangbien’s picture

Thanks you very much,
It help for me,

Steve -cc’s picture

This code change to line 1528 worked for me too.

I was trying to use Backup and Migrate Module to move a site from my local server to my production server. Turning Safe mode off is not an option for me at my host - Nearly Free Speech.

Should this be made a permanent change?

Here is the change so I can find it easier next time. Seems like I will have to do this every time I install D7 on my server at NFS

Replace line 1528 in file includes/file.inc

which reads:
if (!move_uploaded_file($_FILES['files']['tmp_name'][$source], $file->uri)) {
with:
// next line is the original
//if (!move_uploaded_file($_FILES['files']['tmp_name'][$source], $file->uri)) {

// This is a code change as suggested in Drupal Forum - http://drupal.org/node/1099160#comment-4470794
if (!move_uploaded_file($_FILES['files']['tmp_name'][$source], drupal_realpath($file->uri))) {

Thanks leelouch !!
Steve

texis’s picture

Same problem, same solution. Thanks.

Does anybody knows how to report this officialy? I assume an official patch would be fine for this if this is a real issue.

TC

texis’s picture

OK, I found somewhere an easy solution.

in the /includes/file.inc there is line (somewhere around number 1524)
if (!move_uploaded_file($_FILES['files']['tmp_name'][$source], $file->uri)) {
and its last part has to be modified to
if (!move_uploaded_file($_FILES['files']['tmp_name'][$source], drupal_realpath($file->uri))) {

And that's it.

Tex

Ionut Adrian Luchian’s picture

I downloaded the drupal 7.7 core, I ftp it on a server and I installed drupal 7.
I clicked on "My account" then "Edit" and I tryed to upload a profile picture when this warning appeared:
""

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to access temporary://specialed_0.jpg in file_save_upload() (line 1541 of /home/x4locals/public_html/ucreateawebsite.com/includes/file.inc).
    File upload error. Could not move uploaded file.

""

I tried to modify this line ""if (!move_uploaded_file($_FILES['files']['tmp_name'][$source], $file->uri)) {"" with this line ""if (!move_uploaded_file($_FILES['files']['tmp_name'][$source], drupal_realpath($file->uri))) {"" in includes/file.inc but when I retry to upload my profile picture this error appear:
""

Notice: Use of undefined constant WATCHDOG_ERR - assumed 'WATCHDOG_ERR' in file_unmanaged_copy() (line 909 of /home/x4locals/public_html/ucreateawebsite.com/includes/file.inc).
    PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: 'WATCHDOG_ERR' for column 'severity' at row 1: INSERT INTO {watchdog} (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => file [:db_insert_placeholder_2] => The specified file %file could not be copied to %destination. [:db_insert_placeholder_3] => a:2:{s:5:"%file";s:27:"temporary://specialed_0.jpg";s:12:"%destination";s:42:"public://pictures/picture-1-1313830020.jpg";} [:db_insert_placeholder_4] => WATCHDOG_ERR [:db_insert_placeholder_5] => [:db_insert_placeholder_6] => http://ucreateawebsite.com/user/1/edit?render=overlay&render=overlay [:db_insert_placeholder_7] => http://ucreateawebsite.com/user/1/edit?render=overlay [:db_insert_placeholder_8] => 79.112.11.248 [:db_insert_placeholder_9] => 1313830020 ) in dblog_watchdog() (line 157 of /home/x4locals/public_html/ucreateawebsite.com/modules/dblog/dblog.module).

""

nardberjean’s picture

edwu’s picture

I had this issues but there was some restrictions on the storage or bandwidth - do this check first - it might save you some trouble without editing the core files.

usamanisarkhan’s picture

ol the settings are at 777 still it duznt work