Jump to content

Uploading .xls with rename


PC Nerd

Recommended Posts

Hi,  Im trying to upload an excel spreadsheet and rename it to file{timestamp}.xls.  At the moment I'm getting a Permisison Denied error from move_uploaded_file( and its to a folder that is 777 permissions).

 

Thanks

 

<?php
else if(isset($_GET['checkin'])) {

    if (($_FILES["file"]["type"] == "application/octet-stream" || $_FILES["file"]["type"] == "application/vnd.ms-excel") && $_FILES["file"]["size"] < 2000000) {
        if ($_FILES["file"]["error"] > 0) {
            echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
        }
        else {
            if(is_uploaded_file($_FILES["file"]["tmp_name"])) {
                
                echo $_FILES["file"]["name"];
                $newfile = make_directory(getcwd()).basename(str_replace("&&&", time(), $basename));
                echo "upload file: [".$newfile."]"; // usr DIRECTORY_SEPERATOR instead of make_directory();
                if(@move_uploaded_file($_FILES["file"]["tmp_name"], $newfile)) {
                
                    //rename($_FILES['file']['name'], str_replace("&&&", time(), $basename));
                    $currentlock = loadcurrentlockdata();
                    setlock(UNLOCKED);
                    setcurrentlockdata(NULL);
                    writelog("IN"."|".$currentlock[0]."|".time()."\n");
                }
                else {
                    echo "Failed to upload the file.  Please try again";
                }
            }
            else {
                echo "Checkin failed.";
            }
        }
    }
    else
      {
      echo "Invalid file.  Either you have uploaded the wrong file, or it is too big. [".$_FILES["file"]["type"]."][".$_FILES["file"]["size"]."]";
      }
}?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.