SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jun 2002
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Uploading in safe mode

    Its me again..

    Again, im working on my clients site, the sites completly done, except the admin section. Now, when i try to upload files, it gives me an error like "Warning: Unable to create './screenshots/file.gif': Permission denied in /home/virtual/site166/fst/var/www/html/race/upload.php on line 24

    Warning: Unable to move '/tmp/phpEW5Ukj' to './screenshots/file.gif' in /home/virtual/site166/fst/var/www/html/race/upload.php on line 24
    Could not copy file"

    I've tried many, many different scripts to no avail. The script im trying at the moment is one i got off of zend.com.

    PHP Code:
    <?php
    // this is the directory that the uploaded Statistics Digest will be kept in.
    $dirname "/screenshots";

    //this is the full path of the Uploaded Statistic Digest
    define(PATH,"/var/www/html/race");

    //gets the filename and extension from the file input in the form
    $filename $files_name;
    $accept_mtype "image/gif";
    $m_type =  $HTTP_POST_FILES['files']['type'];
    /*Checks whether input file exists  & checks to see whether the file is a pdf
    file. It only uploads PDF files
    */
    if (($filename !="") && ($m_type == "image/gif" ))
    {

       
    //checks to see whether the upload directory exists, if not, creates it
       
    if (!$dir = @opendir(PATH.$dirname))
           
    mkdir(PATH.$dirname,0700) or die
           (
    "Could not create directory");

       
    //copy the uploaded file from the temporary dir to the statdigest dir.
       
    move_uploaded_file($files,$dirname."/".$files_name) or die
       (
    "Could not copy  file");
       
    unlink($files) or die
       (
    "Could not delete uploaded file");
       echo 
    "File Uploaded Successfully";

    }

    elseif (
    $filename ==""){
            echo 
    "You must  Select a File to upload";
            }

    else {
    echo 
    "You are only allowed to upload PDF files";
    }
    ?>
    <html>
    <head>
    <title>Successful File Upload!!</title>
    <body>
    <P>You Sent: <? echo $_FILES['']['name'?>, a <? echo $_FILES['files']['size'];?>
    byte file with a mime type of <? echo $m_type ?>.</p>
    </body>
    </html>

  2. #2
    SitePoint Member
    Join Date
    Jun 2002
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, i got it, there was nothing wrong with the script, just wrong with the folder permissions, sorry to be such a bother, its been a while since i've used PHP and I can barley remember anything.


Bookmarks

Posting Permissions

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