Reputation: 2951
I am running a website with the CodeIgniter framework and I have multiple pages from which users can upload files (profile pictures etc.).
This used to work fine until I recently deleted and replaced the uploads folder on the server. I set the permissions to 777 using FileZilla and confirmed the permissions were actually set afterwards. Still I got the CI error The upload destination folder does not appear to be writable.
This error comes from the following function in system/core/Common.php (part of the CI framework) at the indicated line:
if ( ! function_exists('is_really_writable'))
{
function is_really_writable($file)
{
// If we're on a Unix server with safe_mode off we call is_writable
if (DIRECTORY_SEPARATOR == '/' AND @ini_get("safe_mode") == FALSE)
{
return is_writable($file);
}
// For windows servers and safe_mode "on" installations we'll actually
// write a file then read it. Bah...
if (is_dir($file))
{
$file = rtrim($file, '/').'/'.md5(mt_rand(1,100).mt_rand(1,100));
if (($fp = @fopen($file, FOPEN_WRITE_CREATE)) === FALSE)
{
return FALSE; // RETURNS FALSE HERE <---
}
fclose($fp);
@chmod($file, DIR_WRITE_MODE);
@unlink($file);
return TRUE;
}
elseif ( ! is_file($file) OR ($fp = @fopen($file, FOPEN_WRITE_CREATE)) === FALSE)
{
return FALSE;
}
fclose($fp);
return TRUE;
}
}
I have no idea what causes this. The folder path and permissions are exactly the same as before (in fact the permissions used to be stricter) and I haven't changed the script for my upload form. Everything works perfectly fine when I test it locally using Wamp.
Upvotes: 0
Views: 3054
Reputation: 3337
Have you checked owner and group of uploads directory? If you are runing your server under Apache change group to your apache group (usually www-data or http) using chown command.
Upvotes: 1