hi guys, hope u can help me out on this one
i am trying to use this technique to upload jpeg files to a server
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
whenever i upload something, the echos tell me the file name and size and type and where it was stored in, but when i check the folder there is nothing there
Show us the HTML form as well as the PHP script/code that you have.
The script works. You are sending jpg or gif images with maximum size of 20k?
Upload.html:
<html>
<body>
<form action=“upload_file.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>
</body>
</html>
upload_file.php:
<?php
if ((($_FILES[“file”][“type”] == “image/gif”)
|| ($_FILES[“file”][“type”] == “image/jpeg”)
|| ($_FILES[“file”][“type”] == “image/pjpeg”))
&& ($_FILES[“file”][“size”] < 20000))
{
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 />”;
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
}
else
Remember to set permission (chmod) in upload folder.
Rubble
January 2, 2012, 4:57pm
4
As Raju says what code are you using; if you read the page you linked to the first example just saves a tempory image. You need to use the last example which save the image for you to use.
system
January 3, 2012, 2:27am
5
chopficaro:
hi guys, hope u can help me out on this one
i am trying to use this technique to upload jpeg files to a server
http://www.w3schools.com/php/php_file_upload.asp
whenever i upload something, the echos tell me the file name and size and type and where it was stored in, but when i check the folder there is nothing there
The example on the w3schools site works fine
If your code isn’t working properly then you haven’t followed the w3schools example correctly. Post your code so we can see what you have done.