Find the answer to your Linux question:
Results 1 to 5 of 5
I have installed LAMP server(Linux Apache, Mysql and PHP) in my suse11, and it's working well. I got an scrip for uploading file but it doesn't upload my file: first ...
  1. #1
    Just Joined!
    Join Date
    Aug 2008
    Posts
    6

    Question Permissions for file uploading script in php

    I have installed LAMP server(Linux Apache, Mysql and PHP) in my suse11, and it's working well.

    I got an scrip for uploading file but it doesn't upload my file:

    first HTML page
    Code:
    <form enctype="multipart/form-data" action="uploader.php" method="POST">
    <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
    Choose a file to upload: <input name="uploadedfile" type="file" /><br />
    <input type="submit" value="Upload File" />
    </form>

    action of that page, uploader.php:
    Code:
    $target_path = "uploads/";
    
    $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 
    
    if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
        echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
        " has been uploaded";
    } else{
        echo "There was an error uploading the file, please try again!";
    }
    What should i do? i think the problem is with permissions! can anyone help me?

  2. #2
    Just Joined!
    Join Date
    Aug 2008
    Location
    Boston, MA
    Posts
    10
    What user does your web server run as? Often this is 'nobody' or apache, not sure what the default is for Suse, but use 'ps' or check your httpd.conf file to find out. Then make sure that user has permissions to write to the target path.

    To get started, I would also make target path a complete path, like '/home/uploads' so you know for sure where the file is being written to. Then work your way back to any dynamic path you'd like once the rest works.

    And, of course, if you haven't already, find and read the error_log file for your apache install (check httpd.conf for location) as this usually has very specific descriptions of the error.

    Lastly, check the variable $_FILES['userfile']['error'] for error codes explained in PHP: Error Messages Explained - Manual

    Good Luck! -TC

  3. #3
    Just Joined!
    Join Date
    Aug 2008
    Posts
    6

    user

    i checked it in uid.conf!
    user was wwwrun and group was www!

    now what should i do?

  4. #4
    Just Joined!
    Join Date
    Aug 2008
    Location
    Boston, MA
    Posts
    10
    I generally create a folder for these uploads. Create a new folder, owned by wwwrun with owner write permissions...

    > mkdir /home/uploads
    > chown wwwrun:www /home/uploads
    > chmod 775 uploads

    Change your target_path to '/home/uploads'

    See if you can upload now. I would, of course, not trust any uploaded files...have another process check and relocate these files as necessary before posting them for other viewers. Remember that if the web server can save files here, the web server can corrupt the files here.

  5. #5
    Just Joined!
    Join Date
    Aug 2008
    Posts
    6
    I made an "uploads" folder in "/"
    i did all the things u said:
    # mkdir /uploads
    # chown wwwrun:www /uploads
    # chmod 777 uploads
    but i can't upload file! i don't recieve any message: "There was an error..."
    in error log i saw a syntax error: unexpected ',' in ".../uploader.php"...

Posting Permissions

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