Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
367 views
in Technique[技术] by (71.8m points)

php - 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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); 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...