Discussion: File upload problem
Afficher un message
Vieux 18/02/2008, 12h07   #1
kodaliece@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut File upload problem

Hi All,

I am using a simple php script to learn file upload functionality in
php.

Below is my html form code:
<html>
<title>
File Upload FORM
</title>
<body>
<form action="upload_file.php" method="POST" enctype="multipart/form-
data">
Select your file: <input type="file" name="inputFile"
id="inputFile">
<BR>
<input type="submit" value="Upload">
</form>
</body>
</html>

and my upload_file.php file is:
<?php
// chekc the type of the content uploaded
if (($_FILES["inputFile"]["type"] == "image/gif") ||
($_FILES["inputFile"]["type"] == "image/jpg") ||
($_FILES["inputFile"]["type"] == "image/pjpeg") &&
($_FILES["inputFile"]["size"] > 20000))
{
if ($_FILES["inputFile"]["error"] > 0)
echo "Error: ".$_FILES["inputFile"]["error"]."<br/>";
else
{
if (file_exists("upload/".$_FILES["inputFile"]["name"]))
echo "Error: File \""."upload/".$_FILES["inputFile"]["name"]."\"
already exists!";
else
{
move_uploaded_file($_FILES["inputFile"]["tmp_name"], "upload/".
$_FILES["inputFile"]["name"]);
echo "Stored the file: ".$_FILES["inputFile"]["name"];
}
}
}
else
{
echo "Invalid File";
}
?>

But this is not uploading the file and is always printing "Invalid
File". So I tried to echo the file name, type, size and error values.
But its printing nothing. The same code worked with IIS. But, now I am
using tomcat and its not working.

Can any one please me on this.

Thanks in advance,
Mohan
  Réponse avec citation
 
Page generated in 0,06108 seconds with 9 queries