View Full Version : file uploading - permission error

01-12-2004, 07:10 AM
I am trying file uploading and am getting stuck on 1 error.

The error is:

Warning: Unable to create '/uploadsimg40023a1816ef0.jpg': Permission denied in /...php on line 12

My code is:

if(isset($_POST['add'])) {

$upload_path = '/uploads';
$source = $HTTP_POST_FILES['image']['tmp_name'];
$dest = '';

if(($source != "none") && ($source != "")){
$dest = $upload_path.uniqid('img').".jpg";

if(move_uploaded_file($source, $dest)) {
echo "File: $dest successfully stored";
} else {
echo "File could not be stored";

} else {
echo "File not supplied";

I'm sure the code is fine but I need to do something with the permissions? some sort of setting perhaps?

01-12-2004, 10:27 AM

you'll have to chmod the directory that you want to uplaod the image to, using an ftp-program (eg. Wsftp). With chmod you can set the read/write/execute permissions of files and directories for different users. If you allow all actions by all users (chmod 777) I'm sure that your script will work. Possibly you can do with less permissions, but I'm not sure what would be sufficient. Perhaps anyone can shine a light on that one ...

Cheers, Michiel

01-13-2004, 06:41 AM
Thanks, I used ftp surfer and changed the permissions on ht e"images" folder which i am trying to move to as so:

...but am still getting the error

Warning: Unable to create 'preview/news/images/img4003836877aad.jpg': Permission denied in /..test.php on line 12

Warning: Unable to move '/var/tmp/php041Mb4' to 'preview/news/images/img4003836877aad.jpg' in /...test.php on line 12


01-16-2004, 11:34 PM

sorry for my delayed reply, I've been busy these past few days ... Well back to your problem: I'm not sure why changing the permissions of the 'images'-directory doesn't work.

I'll have a look at your code .. perhaps I can find the error there!