Remote file upload

This is my normal file upload code.

HTML

<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1"> <input name="theFile" type="file" /> <input name="Submit" type="submit" value="Upload"> </form> 

PHP variables to get the file

 $fileName = $_FILES['theFile']['name']; $fileTempName = $_FILES['theFile']['tmp_name']; 

Now I would like to use remote download.

So, I created this form

 <form method="POST" action="<?=$self?>"> <input type="text" name="file[]" size="45" value=""> <input name="submit" type="submit" id="submit" value="submit" accesskey="s"></p> </form> 

I need to enter url file in the form above. When I submit the form, I want to save the file file data in these variables $fileName,$fileTempName

I do not want them stored locally. I am trying to use these variables in amazon s3 boot. Can you guys help me ?. Thanks

+4
source share
2 answers

Try the following:

 $ch = curl_init("http://www.remotepage.com/upload.php"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CUROPT_POSTFIELDS, array('fileupload' => '@'.$_FILES['theFile']['tmp_name'])); echo curl_exec($ch); 
+3
source

Are you trying to make a remote download, but can you re-upload it to your server? Why don't you just submit your form to the download location and try it? This is the fastest and best solution.

0
source

All Articles