• <bdo id='BDoK5'></bdo><ul id='BDoK5'></ul>
    1. <legend id='BDoK5'><style id='BDoK5'><dir id='BDoK5'><q id='BDoK5'></q></dir></style></legend>

      <tfoot id='BDoK5'></tfoot>

      <i id='BDoK5'><tr id='BDoK5'><dt id='BDoK5'><q id='BDoK5'><span id='BDoK5'><b id='BDoK5'><form id='BDoK5'><ins id='BDoK5'></ins><ul id='BDoK5'></ul><sub id='BDoK5'></sub></form><legend id='BDoK5'></legend><bdo id='BDoK5'><pre id='BDoK5'><center id='BDoK5'></center></pre></bdo></b><th id='BDoK5'></th></span></q></dt></tr></i><div id='BDoK5'><tfoot id='BDoK5'></tfoot><dl id='BDoK5'><fieldset id='BDoK5'></fieldset></dl></div>

      1. <small id='BDoK5'></small><noframes id='BDoK5'>

        从服务器到服务器的http传输文件

        时间:2023-05-21

        <i id='wDvHc'><tr id='wDvHc'><dt id='wDvHc'><q id='wDvHc'><span id='wDvHc'><b id='wDvHc'><form id='wDvHc'><ins id='wDvHc'></ins><ul id='wDvHc'></ul><sub id='wDvHc'></sub></form><legend id='wDvHc'></legend><bdo id='wDvHc'><pre id='wDvHc'><center id='wDvHc'></center></pre></bdo></b><th id='wDvHc'></th></span></q></dt></tr></i><div id='wDvHc'><tfoot id='wDvHc'></tfoot><dl id='wDvHc'><fieldset id='wDvHc'></fieldset></dl></div>

            <small id='wDvHc'></small><noframes id='wDvHc'>

              <bdo id='wDvHc'></bdo><ul id='wDvHc'></ul>
              <tfoot id='wDvHc'></tfoot>

                  <tbody id='wDvHc'></tbody>
                1. <legend id='wDvHc'><style id='wDvHc'><dir id='wDvHc'><q id='wDvHc'></q></dir></style></legend>
                  本文介绍了从服务器到服务器的http传输文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  使用 html 表单,我们可以使用 enctype="multipart/form-data" 将文件从客户端上传到服务器,输入 type="file" 等等在.

                  with html forms we can upload a file from a client to a server with enctype="multipart/form-data", input type="file" and so on.

                  有没有办法让一个文件已经在服务器上,然后以同样的方式将它传输到另一台服务器?

                  Is there a way to have a file already ON the server and transfer it to another server the same way?

                  感谢提示.

                  //哇!这是我见过最快的问答页面!!

                  // WoW! This is the fastest question answering page i have ever seen!!

                  推荐答案

                  当浏览器将文件上传到服务器时,它会发送一个包含文件内容的 HTTP POST 请求.

                  When the browser is uploading a file to the server, it sends an HTTP POST request, that contains the file's content.

                  你必须复制它.


                  对于 PHP,最简单的(或者至少是最常用的) 解决方案可能是使用 curl.


                  With PHP, the simplest (or, at least, most used) solution is probably to work with curl.

                  如果您查看可以使用 curl_setopt,你会看到这个:CURLOPT_POSTFIELDS (引用):

                  If you take a look at the list of options you can set with curl_setopt, you'll see this one : CURLOPT_POSTFIELDS (quoting) :

                  要在 HTTPPOST"中发布的完整数据手术.
                  要发布文件,在文件名前面加上@ 并使用完整路径.
                  这可以是作为 urlencoded 字符串传递,如'para1=val1&para2=val2&...' 或作为以字段名称为键的数组和字段数据作为值.
                  如果值是一个数组,Content-Type 标头将设置为 multipart/form-data.

                  The full data to post in a HTTP "POST" operation.
                  To post a file, prepend a filename with @ and use the full path.
                  This can either be passed as a urlencoded string like 'para1=val1&para2=val2&...' or as an array with the field name as key and field data as value.
                  If value is an array, the Content-Type header will be set to multipart/form-data.


                  未经测试,但我认为这样的事情应该可以解决问题 - 或者至少
                  帮助您入门:


                  Not tested,but I suppose that something like this should do the trick -- or at least
                  help you get started :

                  $ch = curl_init();
                  curl_setopt($ch, CURLOPT_URL, "http://www.example.com/your-destination-script.php");
                  curl_setopt($ch, CURLOPT_HEADER, false);
                  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                  curl_setopt($ch, CURLOPT_POST, true);
                  curl_setopt($ch, CURLOPT_POSTFIELDS, array(
                          'file' => '@/..../file.jpg',
                           // you'll have to change the name, here, I suppose
                           // some other fields ?
                  ));
                  $result = curl_exec($ch);
                  curl_close($ch);
                  

                  基本上,你:

                  • 正在使用 curl
                  • 必须设置目标网址
                  • 表示你希望curl_exec返回结果,而不是输出它
                  • 正在使用 POST,而不是 GET
                  • 正在发布一些数据,包括一个文件 -- 请注意文件路径前的 @.
                  • are using curl
                  • have to set the destination URL
                  • indicate you want curl_exec to return the result, and not output it
                  • are using POST, and not GET
                  • are posting some data, including a file -- note the @ before the file's path.

                  这篇关于从服务器到服务器的http传输文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                    <bdo id='BeptK'></bdo><ul id='BeptK'></ul>
                    <tfoot id='BeptK'></tfoot>
                      <i id='BeptK'><tr id='BeptK'><dt id='BeptK'><q id='BeptK'><span id='BeptK'><b id='BeptK'><form id='BeptK'><ins id='BeptK'></ins><ul id='BeptK'></ul><sub id='BeptK'></sub></form><legend id='BeptK'></legend><bdo id='BeptK'><pre id='BeptK'><center id='BeptK'></center></pre></bdo></b><th id='BeptK'></th></span></q></dt></tr></i><div id='BeptK'><tfoot id='BeptK'></tfoot><dl id='BeptK'><fieldset id='BeptK'></fieldset></dl></div>

                      <small id='BeptK'></small><noframes id='BeptK'>

                    1. <legend id='BeptK'><style id='BeptK'><dir id='BeptK'><q id='BeptK'></q></dir></style></legend>

                          <tbody id='BeptK'></tbody>