Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Aug 2002
    Posts
    151
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy file uploading - permission error

    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:
    PHP Code:
    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?

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Location
    The Netherlands
    Posts
    252
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,

    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

  • #3
    Regular Coder
    Join Date
    Aug 2002
    Posts
    151
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    Regular Coder
    Join Date
    Jul 2002
    Location
    The Netherlands
    Posts
    252
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,

    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!

    Michiel


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •