G
gradinafrica
Guest
I am trying to make a php uploader.
I want it to upload only image files, but I'll worry about that later, once I can actually the barebones of the script to work. I have this script, which I got from www.w3schools.com:
<?php
if ($_FILES["file"]["size"] < 2000000)
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
else
{
echo "Invalid file";
}
?>
and I've got this code, which I've got from the same site:
<form action="page.php?type=admin_control_panel.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>
For some reason, it simply won't upload the file. Do I need to somehow tell it to overwrite any file that it sees? Because I think that there was a file with the same name in the destination.
What is going wrong?
I want it to upload only image files, but I'll worry about that later, once I can actually the barebones of the script to work. I have this script, which I got from www.w3schools.com:
<?php
if ($_FILES["file"]["size"] < 2000000)
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
else
{
echo "Invalid file";
}
?>
and I've got this code, which I've got from the same site:
<form action="page.php?type=admin_control_panel.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>
For some reason, it simply won't upload the file. Do I need to somehow tell it to overwrite any file that it sees? Because I think that there was a file with the same name in the destination.
What is going wrong?