Helo Guys! Hi I keep receiving this error.. can someone explain to me why this happen?
==========================
Upload: 165343_1803646733550_1311313795_2080049_5276461_n.jpg
Type: image/jpeg
Size: 84.056640625 Kb
Stored in: C:\xampp\tmp\php2E50.tmp
Warning: move_uploaded_file(C://xamp/htdocs/Lacson_exam/files/165343_1803646733550_1311313795_2080049_5276461_n.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\xampp\htdocs\exercise\upload_file.php on line 20
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\xampp\tmp\php2E50.tmp' to 'C://xamp/htdocs/Lacson_exam/files/165343_1803646733550_1311313795_2080049_5276461_n.jpg' in C:\xampp\htdocs\exercise\upload_file.php on line 20
Stored in: C://xamp/htdocs/Lacson_exam/files/165343_1803646733550_1311313795_2080049_5276461_n.jpgInvalid file
======================================================================================================
heres my script.
<?php
if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_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 "Stored in: " . $_FILES["file"]["tmp_name"];
}
if (file_exists("C://xamp/htdocs/Lacson_exam/files/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"C://xamp/htdocs/Lacson_exam/files/" . $_FILES["file"]["name"]);
echo "Stored in: " . "C://xamp/htdocs/Lacson_exam/files/" . $_FILES["file"]["name"];
}
echo "Invalid file";
?>
File upload directory
Moderator: General Moderators
Re: File upload directory
Can you post your form aswell?
Re: File upload directory
heres my form..
<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>
<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>
-
yassinebelkaid
- Forum Newbie
- Posts: 1
- Joined: Sat Oct 08, 2011 2:54 pm
Re: File upload directory
Hi Jauson, I think instead of writing : move_uploaded_file($_FILES["file"]["tmp_name"],
"C://xamp/htdocs/Lacson_exam/files/" . $_FILES["file"]["name"]);
simply create a variable called $path = "Lacson_exam/files/" .$_FILES["file"]["name"]";
and replace "C://xamp/htdocs/Lacson_exam/files/" . $_FILES["file"]["name"]); by $path.
Hope you the best!
"C://xamp/htdocs/Lacson_exam/files/" . $_FILES["file"]["name"]);
simply create a variable called $path = "Lacson_exam/files/" .$_FILES["file"]["name"]";
and replace "C://xamp/htdocs/Lacson_exam/files/" . $_FILES["file"]["name"]); by $path.
Hope you the best!