需要远程文件上传帮助 [英] Remote file upload help needed

查看:166
本文介绍了需要远程文件上传帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

资挥读范范辛


HTML




 < form action =method =postenctype =multipart / form-dataname =form1id =form1> 
< input name =theFiletype =file/>
< input name =Submittype =submitvalue =Upload>
< / form>




接收文件的PHP变量



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

现在我想使用远程上传功能。



所以我创建了一个这样的表单

 < form method =POSTaction =<?= $自>> 
< input type =textname =file []size =45value =>
< input name =submittype =submitid =submitvalue =submitaccesskey =s>< / p>
< / form>

我必须在上述表格中输入文件的网址。当我提交表单我想要文件的详细信息存储在这些变量 $ fileName,$ fileTempName



我不不希望他们在本地存储。我试图在亚马逊s3上传中使用这些变量。你们能帮我吗?谢谢

解决方案

试试这个:

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


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

解决方案

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, CUROPT_POSTFIELDS, array('fileupload' => '@'.$_FILES['theFile']['tmp_name'])); 
echo curl_exec($ch); 

这篇关于需要远程文件上传帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆