Jump to content

Moving an uploaded image


crouchjay

Recommended Posts


[code]$success=move_uploaded_file($_FILES["imgfile"]['tmp_name'], 'C:\Apache2\htdocs\GP2\imageEditing\\'.$_FILES["imgfile"]['name']);[/code]

I have WINDOWS OS and all file directory names are correct. It returns false. Please help

Thanks.

Jay.
Link to comment
Share on other sites

Thanks, but unfortunately that didn't work. I also tried changing the slashes around but that didn't help either.
[code]
$image=new Image();
$file=$_FILES["imgfile"]['type'];
$ext=$image->verifyImage($file);
if(strlen($ext)>4){echo $ext; exit();}//Display error message, needs to be finished
$filename='temp_img'.$ext;
$image->setFilename($path_username_temp.'\\'.$filename);
$error=$image->uploadImage("imgfile", $path_username_temp, '\\'.$filename);
$success=move_uploaded_file($_FILES["imgfile"]['tmp_name'], 'C:\Apache2\htdocs\GP2\imageEditing\\'.$_FILES["imgfile"]['name']);
if($success==false) echo "false";
else echo "true";
[/code]

This is what the code looks like around it. The rest works as intended.

Jay
Link to comment
Share on other sites

Well, here's a snippet from one of my upload files... I'm running Win 2000 on IIS 5 (I WISH I had Apache):
[code]
$uploaddir = 'C:\\Inetpub\\wwwroot\\Durb\\upload\\';
    if(substr(basename($_FILES['userfile']['name']),-4) != '.csv')
    {
        echo "<p class=\"warn\">Only CSV files will be accepted as input.</p><br/>";
        $showform = 1;
        if(isset($_REQUEST['oil']))
            $_REQUEST['uload'] = 1;
    }
    else
    {
        $tempfilename = substr(basename($_FILES['userfile']['name']),0,-4) . "-" . date("njYhis") . ".csv";
        $uploadfile = $uploaddir . $tempfilename;
        echo "<p class=\"other\">Filename:  " . $_FILES['userfile']['name'] . "</p>";
        echo "<p class=\"other\">Temporary Filename:  " . $tempfilename . "</p>";
        echo "<p class=\"other\">File size:  " . $_FILES['userfile']['size'] . "</p>";
        echo "<p class=\"other\">File type:  " . $_FILES['userfile']['type'] . "</p>";
    
        if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))
        {
            echo "<br/><p class=\"norm2\" style=\"color:green\">File is valid, and was successfully uploaded and relocated.</p><br/>";
[/code]
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.