| 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

msg:3527781 | 3:40 pm on Dec 14, 2007 (gmt 0) | 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?
<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"] < 300000)) { 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"; } ?>
|
| [edited by: master_w_bates_III at 3:43 pm (utc) on Dec. 14, 2007]
|
joelgreen

msg:3527900 | 5:15 pm on Dec 14, 2007 (gmt 0) | Welcome to WebmasterWorld master w bates III You cannot upload file via URL as far as i know.
|
master w bates III

msg:3528435 | 10:39 am on Dec 15, 2007 (gmt 0) | 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. <snip> 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> <br> </div>
|
| 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]
|
mikesmith76

msg:3528500 | 2:10 pm on Dec 15, 2007 (gmt 0) | 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
|
|
|