File upload script problem on OS X server

Discussion in 'Mac Programming' started by moron, Jun 7, 2006.

  1. macrumors newbie

    Joined:
    Apr 9, 2003
    Location:
    London
    #1
    Hi,

    I'm having a problem with my local OS X web server, and it's driving me insane. I'm trying to teach myself php, and I've made a script to upload a file from my machine to the server...the problem is that the upload keeps failing. At first I assumed this was a problem with my code, but there are no syntax errors and it runs flawlessly on my paid webhost. This suggests that there's something wrong with my local webserver. I've tried Googling for an answer, but with no joy....and I was hoping that someone here might be able to help.

    Here's the code I'm using...

    PHP:
    <?php if ($_FILES['File']) { ?>
       <p>File name: <?php echo $_FILES['File']['name'?></p>
       <p>File size: <?php echo $_FILES['File']['size'?></p>
       <?php 
            
    if (copy ($_FILES['File']['tmp_name'], "img/$File_name")) {
             
    $Outcome = ("Your file was successfully uploaded!");
         } else {
             
    $Outcome = ("Your file could not be copied.");
         }
         
    unlink ($_FILES['File']['tmp_name']);
        
    ?>
        <p><?php echo $Outcome ?></p>
    <?php ?>

    <p>Upload a file to the server:</p>
    <form action="uploadtest2.php" method="post" enctype="multipart/form-data">
       <!-- allow browsers to detect when file > max file size -->
       <input type="hidden" name="MAX_FILE_SIZE" value="20000000000" />
       <input type="file" name="File" size="20"><br />
       <input type="submit" name="SUBMIT" value="Submit!">
    </form>
    I've chmod 777 the 'img' folder, so I don't think it's a permissions issue. :|

    The server is running OS X 10.3.9 with the Entropy php package.

    If anyone could perhaps speculate why this is happening, I'll be eternally grateful! :)
     
  2. macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Location:
    Fuquay Varina, NC
    #2
    Whats the value of $File_name?

    Always use a full path in your destination - you cannot assume the base folder is the current folder.

    Have you tried move_uploaded_file() instead?
     

Share This Page