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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Oct 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP file upload issue

    I'm trying to develop a simple Flash video upload site for a client and I've run into something I haven't really dealt too much with: an automated user upload page. I'm starting off at the simplest level by just trying to make a page that lets you upload a file up to a 100k, and its giving me back errors. I'm guessing this may be because I need to activate some sort of permission on my web space to be able to write, but it also might be something with the code.

    Here's what I have made so far with uploader.php:

    Code:
    <?php
    // Where the file is going to be placed 
    $target_path = "uploads/";
    
    /* Add the original filename to our target path.  
    Result is "uploads/filename.extension" */
    $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 
    $_FILES['uploadedfile']['tmp_name'];  
    
    $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!";
    }
    ?>
    By the way, the script was taken from: http://www.tizag.com/phpT/fileupload...LE_SIZE=100000

    I've tried modifying the $target_path to go to the exact path of the site and not go into the uploads folder, but the folder before that which is "fullScreen".

    The result of choosing a file and uploading is "Warning: move_uploaded_file(uploads/Buzzy Beetle.gif): failed to open stream: Permission denied in /home/vectors/public_html/fullScreen/uploader.php on line 14"

    and..

    'Warning: move_uploaded_file(): Unable to move '/tmp/phpzjYA8l' to 'uploads/Buzzy Beetle.gif' in /home/vectors/public_html/fullScreen/uploader.php on line 14
    There was an error uploading the file, please try again!"

    If you want to see and try the upload page for yourself, it's right here.

    I just want to note that all the permission settings for the upload folder are all checked, including world.

    Thanks!

  • #2
    New Coder
    Join Date
    Nov 2005
    Posts
    97
    Thanks
    1
    Thanked 0 Times in 0 Posts
    the destination must be a complete address, so $_SERVER['DOCUMENT_ROOT']."/gallery/".$newname

    just as $_FILES["filename"]["tmp_name"] willl be something like c:\winnt\temp\45334.tmp

    PHP Code:
    $newname "picture1.jpg";
    upload($newname);

    function 
    upload($newname){
     
    $temp $_FILES["filename"]["tmp_name"];
     if(
    move_uploaded_file($temp$_SERVER['DOCUMENT_ROOT'].'/gallery/'.$newname)){
      return 
    true;
     }
     return 
    false;

    Last edited by alexpayne; 10-28-2006 at 02:48 PM.
    Edit: Nothing that can be considered offensive in the signature, please. // liorean

    www.moresense.co.uk

  • #3
    New to the CF scene
    Join Date
    Oct 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I checked them all. Set to 777. Tried the form last night, didn't work. Today it worked!!! What?! Does this mean it takes some amount of time for it to work after permissions are changed? I just dont understand. Thanks for all your help though. I wouldn't of known to do this in the first place.


  •  

    Posting Permissions

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