Forum Moderators: coopster
The Code:
<?php
if (isset($_POST['cmdsave'])){
$db_connection='aht';
$con_table = 'brand';
if(!isset($_POST['filelogo'])){$_POST['filelogo'] = '';}
$fileinput = stripslashes($_POST['filelogo']);
$redirect_url = 'view.php';
if(!empty($_POST['filelogo']))
{
$fileext=strstr(basename($fileinput),".");
$filename= $_POST['id'] . "_$con_table" . $fileext;
$query2="UPDATE $con_table SET logo='$filename' where id=". $_POST['id'] ."";
$result2=mysql_query($query2);
if(!copy($fileinput, "/httpdocs/images/brand_images/$filename")) die("Can't copy $fileinput to $filename");
}
if ($redirect_url <> ''){
header("Location: " . $redirect_url); }
}
?>
The Error:
Warning: copy(C:\Documents and Settings\ym\Desktop\picture.gif): failed to open stream: No such file or directory in /home/httpd/vhosts/aht/httpdocs/admin/brand/edit.php on line 69
Can't copy C:\Documents and Settings\ym\Desktop\picture.gif to 10_brand.gif
Whew, what a day - been at this almost endlessly and finally reduced all stuff to the following since my brain couldn't take any more - here's the simplified stuff:
The form:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<form action="upload_file_script.php" method="post" enctype="application/x-www-form-urlencoded" name="upload_file" id="upload_file">
<input name="upload_file" type="file" id="upload_file">
<input name="submit" type="submit" id="submit" value="Submit">
</form>
</body>
</html>
The Script:
<?php
$fileinput = $_POST['upload_file']; //confusion
$filename=basename($fileinput);
if(is_uploaded_file($_POST['upload_file']))
{
echo "The file name is: " . $filename;
} else
{
echo "There seems to be an issue. The file is not uploaded via HTTP Post.";
}
//if(!copy($fileinput,"/images/$filename")) die("Can't copy $fileinput to $filename");
?>
I've commented the last line since the operation still keeps failing and one more thing, the is_uploaded_file keeps returning false be it any of the two EncTypes, application/x-www-form-urlencoded or multipart/form data - which one is used actually?
Finally, found this on the web:
[bugs.php.net...]
...and it might seem this would be the case, however, I'm not too sure - so I posted this entire query to my host also.
I hope I get to the bottom of this. Any help!
Rgds,
YM