Hi:
First of all thanks for your help. I have learned a lot more than when I started on this forum. Now I'm trying to upload files from a local machine to a server and the php code I have is in a file called uploadfile.php and the html code is in profile2.php.
The code for uploadfile.php:
<?php
ini_set('display_errors', 1); error_reporting(~0);
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 60000))
{
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
{
echo "Invalid file";
}
?>
The code for profile2.php is:
<html>
<body>
<form action="uploadfile.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>
The error I get is:
Upload: file_151438.gif
Type: image/gif
Size: 22.447265625 Kb
Temp file: D:\Temp\php\php7CCA.tmp
Warning: move_uploaded_file(upload/file_151438.gif) [function.move-uploaded-file]: failed to open stream: Permission denied in D:\Hosting\7520570\html\india\uploadfile.php on line 28
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'D:\Temp\php\php7CCA.tmp' to 'upload/file_151438.gif' in D:\Hosting\7520570\html\india\uploadfile.php on line 28
Stored in: upload/file_151438.gif
Can someone please help me figure out how to fix this?
Thanks in advance.🙂