Take the 2-minute tour ×

I have a script to upload files to the server from your computer. It works fine and basically it's a

<form enctype="multipart/form-data" action="post_img_upload.php?id='.$topicid.'" method="POST">
<input type="submit" value="Subila" />

then, the post_img_upload.php starts like this:

 $target = "pics/"; 

$fileName = $target . $_FILES["uploaded_file"]["name"];           // The file name
$fileExt = end($kaboom);    

Now I want to have the option to upload a file having an url address. Another form basically with

<form action="post_img_url_upload.php?id='.$topicid.'" method="POST">
<input name="url" type="text" size="100" /> 
<input type="submit" value="Copiar"/>

I would like to have post_img_url_upload.php similar to the post_img_upload.php. How can I approach that? How can I basically write

$fileName = $target . $_FILES["url"]["name"];

? Is it doable? Thanks!

share|improve this question
Nope, you can't use a file input for this. You have to ask the user to input the URL into a text field, and then fetch the URL provided in your PHP script. –  Pekka 웃 Sep 27 '11 at 7:11
add comment

1 Answer

up vote 1 down vote accepted

AFAIK, no. The server would only get the url string, and then should try to fetch the image itself (instead of the image data being transferred from the client). You could google for "php external request" as there are a couple of ways to do it (cURL, remote file access, etc.).

share|improve this answer
add comment

Your Answer


