Upload Error

Permalink
Hi everyone,

I've a concrete5 running but suddenly the file upload appears not function as usual.

A couple of weeks ago the upload was working fine. then it stopped.
I've have checked the whole forum for similar issues but none of these are working.

The error message I get is:

Unable to copy file to storage directory. Please check permissions on your upload directory and ensure they can be written to by your web server.

and this is for multiple or single file uploads!

I've tried php5.ini containing

file_uploads = On
upload_max_filesize = 32M
post_max_size = 32M
upload_tmp_dir = /tmp/


By the way I have tried the folder /temp/ with different file permission (777, 775, 755) including sub-folders and files. Nothing seems to work.

I've tried changing the directories "/file/" permission to 777 / 755 / 775 including sub-folders and files, result unsuccessful!

I've tried using the incoming folder via FileZilla = :(

I checked this discussions:

http://www.concrete5.org/community/forums/block_requests/upload-fil...

http://www.concrete5.org/community/forums/installation/solved-uploa...

Did I miss something? Please anyone with another idea which could help solve this unusual problem?!

primewaydesign
View Replies:
goutnet replied on at Permalink Reply
goutnet
I beleive the message is not complaining about the /tmp folder not being writable, but the destination storage folder not being writable.

you should check that the directory concrete5 stores its file in is writable by the user the server runs (depending on your server).
primewaydesign replied on at Permalink Reply
primewaydesign
Hi goutnet,

thanks for your reply!

The file storage is usually "/file/" on the directory right?

If so I've checked it and it is writable!
goutnet replied on at Permalink Reply
goutnet
did you check if the disk is not full ?

you may want to investigate a bit more by adding some traces in the staging/concrete/core/libraries/file_importer.php file, in the storeFile() method (that's the one responsible for storing the file).
primewaydesign replied on at Permalink Reply
primewaydesign
Hi goutnet,

here's is the file_importer.php from:

concrete / core / libraries / file_importer.php

It there anything wrong?

<?php 
defined('C5_EXECUTE') or die("Access Denied.");
Loader::model('file');
Loader::model('file_version');
/**
 * @package Core
 * @category Concrete
 * @author Andrew Embler <[email protected]>
 * @copyright  Copyright (c) 2003-2009 Concrete5. (http://www.concrete5.org)
 * @license   http://www.concrete5.org/license/...     MIT License
 *
 */
/**
 * @package Core
 * @author Andrew Embler <[email protected]>
goutnet replied on at Permalink Reply
goutnet
No, I meant you should add some traces here and there to see why the file can not be written ...
primewaydesign replied on at Permalink Reply
primewaydesign
I dont get you?!
goutnet replied on at Permalink Reply
goutnet
Well, I am making a wild guess here, but sounds like you are not a coder are you ? :P

To debug this situation, you should modify the core code to add more messages about what is happenning and then fix the situation.

in the function storeFile, the line responsible for moving the uploaded file from /tmp to your final destination is this one :

$r = @copy($pointer, $path);


I would make it this way :

$r = @copy( $pointer, $path);
$f = fopen( '/tmp/store_trace.txt', 'a' );
fwrite( $f, "Trying to move $pointer to $path resulted in return $r\n");
fclose( $f );


This code will create a '/tmp/store_trace.txt' file on the server, and print the relevant message to it.

After modifying the code, you will have more information to post here.

(Specifically, we will know from where to where was the copy, and what was the error code of the copy() call).
JohntheFish replied on at Permalink Reply
JohntheFish
You may find the code snippets in this howto of use for debugging:
http://www.concrete5.org/documentation/how-tos/developers/concrete5...
goutnet replied on at Permalink Reply
goutnet
... right, so you could just change the code I gave you by this :

$r = @copy( $pointer, $path);
Log::addEntry("Trying to move $pointer to $path resulted in return $r");


Then go in the logs (http://yoursite/dashboard/reports/logs) and check for the message.
primewaydesign replied on at Permalink Reply
primewaydesign
Hi,

thanks for your support:

Now C5 logs this:

Trying to move /tmp/phpdgghOU to
/var/www/vhosts/website.net/httpdocs/files/4013/6094/6267/picture.j
pg resulted in return

In the Logs I also got "exceptions"

/var/www/vhosts/website.net/httpdocs/concrete/libraries/3rdparty/Zend/Cache.php:209 Could not determine temp directory, please specify a cache_dir manually (0)

Could it be related to each other?

BTW: the hosting is shared.
goutnet replied on at Permalink Reply
goutnet
Well, so that's the copy function which is failing.

change the code to this :

$r = @copy( $pointer, $path);
$t = print_r( error_get_last(), true );
Log::addEntry("Trying to move $pointer to $path resulted in return $r\n$t");


The second message can be (is probably) related to your problem, it seems that for some reason c5 can not find a valid /tmp directory (that is a directory that is both readable and writable).

Are you 100% sure that the /tmp/ directory can be read by the user from which the server is running ?? and are you sure that the /tmp/ folder is not located on a full disk ?
JohntheFish replied on at Permalink Reply
JohntheFish
If you install the 'constants info' and 'php info' addons (both free), that will enable you to track down what php and concrete both think the temp directory is.
primewaydesign replied on at Permalink Reply 1 Attachment
primewaydesign
Hi,

constants info gives this output:
DIR_FILES_UPLOADED /var/www/vhosts/website.net/httpdocs/files

See also php-info.txt in attachment!

===
BTW: i've changed cache_dir in /concrete/libraries/3rdparty/Zend/Cache/Backend/File.php

to cache_dir:'/temp' after creating a folder in /concrete/temp with chmod 777
primewaydesign replied on at Permalink Reply
primewaydesign
Hi,

I've put the website to virtual hosting using EasyPHP 12.1 and the file upload works fine.

It might be that the hosting settings are wrong? Can that be reason?
If so, how can I check the settings?

The hosting company is domainexpress.co.uk

Services I got on this hosting are:

Apache ASP support No (Component was not installed)
SSI support No
PHP support Yes (PHP 'safe_mode' on)
CGI support Yes
Perl support No
Python support No (Component was not installed)
FastCGI support No
Miva support No (Component was not installed)
ColdFusion support No (Component was not installed)
Web statistics Webalizer (accessible via password protected directory '/plesk-stat/' )
Custom Error Documents No
goutnet replied on at Permalink Reply
goutnet
I am not familiar with this host, but that is most likely the case.

I am not sure here, but AFAIK safe_mode prevents php to create files to some extents, that might be the problem.

Try disabling safe_mode (if you can), or enabling it on your virtual environment to reproduce it, and check again.

If that is not related, come back to my last post to update the tracing code I made you setup, so we can have the exact error.