Jump to content

Archived

This topic is now archived and is closed to further replies.

crouchjay

Moving an uploaded image

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.

Share this post


Link to post
Share on other sites
Try this:
[code]$success=move_uploaded_file($_FILES["imgfile"]['tmp_name'], 'C:\\Apache2\\htdocs\\GP2\\imageEditing\\'.$_FILES["imgfile"]['name']);[/code]

Share this post


Link to post
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

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

×

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.