Uploads directory is not writable

php

Solution

From your above code, it seems your upload path is incorrect:

$upload_dir = "/public_html/site/$companyfolder/uploads";

Should have been something like:

$upload_dir = "/home/youruser/public_html/site/{$companyfolder}/uploads";

The directory needs to be the absolute path or relative. When it's relative, it needs to be relative to where the PHP being called is at.

So you could have used it as `./site/{$companyfolder}/uploads` for example, that is given your php code being used is at `/home/youruser/public_html`.

Problem

I've recently just moved my server to a new host and I'm now having problems with my PHP upload form. Files can not be uploaded. The error I get is: Warning: move_uploaded_file(/public_html/site/abc/uploads/APLICATION.doc) [function.move-uploaded-file]: failed to open stream: No such file or directory in /long/path/apply.php on line 389 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpDAz5QP' to '/public_html/site/uploads/1908131216_APPLICATION.doc' in /long/path/apply.php on line 389 Problem: Could not move file to destination directory not writable /tmp/phpDAz5QP - /public_html/site/abc/uploads/1908131216__APPLICATION.doc I have this little test to see if the directory is writable, and it's not. ``` $upload_dir = "/public_html/site/$companyfolder/uploads"; if(!is_writable($upload_dir)) { $writable = 'not writable'; } else { $writable = 'writable'; } echo $writable; ``` I have the uploads folder set to 777 for permissions. Any ideas of why the directory is not writable?

Original source