Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

upload image to directory with input text form

i can't seem to get it to work without using input="file"


master w bates III

3:40 pm on Dec 14, 2007 (gmt 0)

5+ Year Member

this from the w3c site works just fine. I am really interested in finding a way to upload photos by web url. much like the option that photobucket gives you.

i can't seem to get it to work without using input="file" in the form. is there a simple way to get this to work?

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


if (($_FILES["file"]["type"] == "image/gif")
($_FILES["file"]["type"] == "image/jpeg")
($_FILES["file"]["type"] == "image/pjpeg")
&& ($_FILES["file"]["size"] < 300000))
if ($_FILES["file"]["error"] > 0)
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
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. ";
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
echo "Invalid file";

[edited by: master_w_bates_III at 3:43 pm (utc) on Dec. 14, 2007]


5:15 pm on Dec 14, 2007 (gmt 0)

5+ Year Member

Welcome to WebmasterWorld master w bates III

You cannot upload file via URL as far as i know.

master w bates III

10:39 am on Dec 15, 2007 (gmt 0)

5+ Year Member

Hi Joel, Thanks for the warm welcoming.

I am very certain that this is possible. here is an example. The form is located at the bottom of the page.


here is the html for the form

<div id="fromurl">
<input type="text" name="img_url" value="http://" MAXLENGTH=512><br>
<font size="1">Enter the picture url, example: <i>http://example.com/picture.jpg</i></font>

photobucket also has a similar feature. There must be some server side command to make this work.

Ideally what I want to happen is for the image to be transfered from a remote url, and placed into an uploaded pictures folder on my webserver. then to have the local image url referenced in my database.

[edited by: eelixduppy at 10:57 am (utc) on Dec. 15, 2007]
[edit reason] no URLs, please [/edit]


2:10 pm on Dec 15, 2007 (gmt 0)

5+ Year Member

You could do what you're asking using curl to do a request to the inputted url. If it returns an image you're in business, if not .....

Try reading [php.net...] for examples


Featured Threads

Hot Threads This Week

Hot Threads This Month