Jump to content


Photo

Moving an uploaded image


  • Please log in to reply
4 replies to this topic

#1 crouchjay

crouchjay
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 07 June 2006 - 12:59 PM


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

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

Thanks.

Jay.

#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 07 June 2006 - 01:25 PM

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

Info: PHP Manual


#3 crouchjay

crouchjay
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 07 June 2006 - 01:36 PM

Thanks, but unfortunately that didn't work. I also tried changing the slashes around but that didn't help either.
$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";

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

Jay

#4 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 07 June 2006 - 01:39 PM

Well, here's a snippet from one of my upload files... I'm running Win 2000 on IIS 5 (I WISH I had Apache):
$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/>";

Info: PHP Manual


#5 crouchjay

crouchjay
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 07 June 2006 - 06:50 PM

Found the problem, I am stupid. I had already moved it, I needed rename().




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users