Manoj Manoj - 9 months ago 20
PHP Question

Upload image file using href in move_uploaded_file( ) php

I need some advice and guide line.
I am trying to upload image into a folder using link. And I am unable to upload an image.
I am trying this code. This shows error message :

[function.move-uploaded-file]: failed to open stream: HTTP wrapper does not support writeable connections


if ($_FILES["file"]["error"] > 0)
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";

if (file_exists("" . $_FILES["file"]["name"]))
echo $_FILES["file"]["name"] . " already exists. ";
"" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];


<form action="" method="post"
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="submit" value="Submit" />


Is it possible ?

Answer Source

The destination of the moved file needs to be an absolute path to the server, i.e.

move_uploaded_file( $_FILES["file"]["tmp_name"], $_SERVER['DOCUMENT_ROOT'] ."/uploads/" . $_FILES["file"]["name"]);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download