Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remote file upload help needed

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 receive file

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

Now i would like to use remote upload.

So i created a form like this

<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 have to enter file url in the above form. When i submit the form i want the file file details store in these variables $fileName,$fileTempName

I don't want them to store locally. I'm trying to use those variables in amazon s3 upload. Could you guys help me?. Thanks

like image 941
PrivateUser Avatar asked Aug 05 '11 23:08

PrivateUser


1 Answers

Try this:

$ch = curl_init("http://www.remotepage.com/upload.php"); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('fileupload' => '@'.$_FILES['theFile']['tmp_name'])); 
echo curl_exec($ch); 
like image 93
The Mask Avatar answered Oct 23 '22 07:10

The Mask