Dear All,
Whew, what a day - been at this almost endlessly and still unable to get this through! I'm trying to check file copy features on my web site but for some reason it simply won't work. Here's the form and the script I'm using:
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?
If we uncomment the code, it would always die - could any of our superhero's test this code on your servers?!!
I hope I get to the bottom of this. Any help!
Rgds,
YM
File Copy Issue
Moderator: General Moderators
use [ php ] tags when posting php code in the forums...
use multipart/formdata for your enctype.
you are also not accessing the file properly on the php end.
you need to use the $_FILES[] array...
look here for info on how to handle uploaded files with php.
use multipart/formdata for your enctype.
you are also not accessing the file properly on the php end.
you need to use the $_FILES[] array...
look here for info on how to handle uploaded files with php.