使用PHP的HTTP-Header“Content-Disposition:attachment”的问题

使用这个小函数我想创建一个txt文件并命令浏览器开始下载。
上帝 新闻是,它适用于我的XAMPP。 坏消息是,它不能在我的网络服务器上运行。 该文件显示在浏览器上,而不是启动下载。 我错了什么?</ p>

  public function sendAsFile(){
while(false!== ob_get_clean()){};

标题('Content-Type:text / plain; charset = utf-8');
标题('Content-Disposition:attachment; filename =“export.txt”');
echo $ this-&gt; getString();
}
</ code> </ pre>

这个问题如何在PHP中自动启动下载?并不能解决我的问题。 这只适用于服务器上的文件,但我不想将每个创建的文件存储在我的网站空间上。 我想立即创建并下载它。 我想知道它是否适用于XAMPP但不适用于WWW。</ p>
</ div>

展开原文

原文

With this little function I want to create a txt-file and command the browser to start the download. The god news is, it works on my XAMPP. The bad news is, it doesen‘t work on my webserver. Instead of starting the Download, the file is displayed on the browser. What did I wrong?

public function sendAsFile() {
     while (false !== ob_get_clean()) { }; 
     header('Content-Type: text/plain; charset=utf-8');
     header('Content-Disposition: attachment; filename="export.txt"');
     echo $this->getString();
}

This question How to Automatically Start a Download in PHP? doesn't fixed my problem. That only works with a File on the Server, but i dont want to store every created file on my webspace. I want to create and download it immediately. I'm wondering cause it works on XAMPP but not in the WWW.

dptgpyl61857413
dptgpyl61857413 application/octet-stream不起作用,我之前尝试过。
接近 2 年之前 回复
doudao9896
doudao9896 尝试将内容类型更改为application/octet-stream而不是text/txt(这看起来像是一种奇怪的内容类型)并查看它是否有效。
接近 2 年之前 回复
dongyanju1094
dongyanju1094 如何在PHP中自动启动下载可能重复?
接近 2 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
使用Content-Disposition:附件的PHP中的文件下载问题

<div class="post-text" itemprop="text"> <p>I have a link on my web page to download a .CSV file that I have generated on the server. The code for the download is as follows:</p> <pre><code>//open/save dialog box header('Content-Disposition: attachment; filename="inventoryData.csv"'); //content type header('Content-type: application/excel'); //read from server and write to buffer readfile('spreadsheet/inventory.csv'); </code></pre> <p>When I open the file on the server, it looks just fine. However, when I download the file via the dialog box, it is pre-pending the HTML code for the web page to the .csv file.</p> <p>Any ideas why that would happen? </p> </div>

PDF文件无法下载,报出Response header name 'Content-Disposition:' contains invalid characters.

只有Tomcat8.5.20时是可以下载PDF/CSV/TEXT文件的, 但在导入Apache2.4后,CSV/TEXT文件可以继续下载,但PDF文件无法下载,后台报出Response header name 'Content-Disposition:' contains invalid characters的错误信息。 //PDF文件(无法下载) response.setContentType("application/pdf; charset=UTF-8"); response.setHeader("Content-Disposition", "attachment;filename="+filename); //CSV文件(正常下载) response.setContentType("application/x-msdownload; charset=UTF-8"); response.setHeader("Content-Disposition", "attachment;filename="+filename); //TEXT文件(正常下载) response.setContentType("text/plain"); response.setHeader("Content-Disposition", "attachment;filename="+filename); 通过修改httpd.conf文件,追加HttpProtocolOptions Unsafe可以解决这个问题, 但apache官网由于存在安全风险,并不推荐这么设置。 http://httpd.apache.org/docs/current/en/mod/core.html 求教:除了HttpProtocolOptions Unsafe设置外,可还有好的解决方案?

multipart/form-data上传图片 解析为空

如题 提交格式如下 Content-type: multipart/form-data, boundary=aaaaa --aaaaa content-disposition: form-data; name="name" aaaa --aaaaa content-disposition: form-data; name="image"; filename="image.png" Content-Type: image/png // 这里是关于图片的解码 --aaaaa-- PHP进行解析 $newfilename = "photo/".$_POST['name']."/".$_FILES["image"]["name"]; echo $newfilename; if(move_uploaded_file($_FILES["image"]["tmp_name"], $newfilename)) { echo "上传成功!<br>"; } 打印结果:photo// name和图片信息都没有获取到 求帮助.... 如果我写的不对,应该怎么写呢?

Content-disposition attachment这种方式的sheet设计

如题,我需要 <%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%> <%@ include file="/WEB-INF/inc/include.inc.jsp"%> <%@ page import="java.util.Date"%> <%@ page import="java.text.SimpleDateFormat"%> <meta http-equiv='content-type' content='application/ms-excel;charset=UTF-8'/> <%response.setHeader("Content-disposition", "attachment;filename=" + new String( "未回复录取确认学生".getBytes("gb2312"), "ISO8859-1" )+(new SimpleDateFormat("yyyyMMdd").format(new Date()))+".xls" );%> <table align="center" border=1 cellspacing="0" cellpadding="0" style="vnd.ms-excel.numberformat:@"> <thead> <tr> <th width="150" align="center">学生姓名</th> <th width="150" align="center">学生性别</th> <th width="150" align="center">证件类型</th> <th width="150" align="center">证件号码</th> <th width="150" align="center">出生日期</th> <th width="150" align="center">登记区县</th> <th width="150" align="center">就读意愿</th> <th width="150" align="center">人员类型</th> <th width="150" align="center">报名学校</th> <th width="150" align="center">志愿性质</th> <th width="150" align="center">学校发送录取确认通知时间</th> <th width="150" align="center">联系方式</th> </tr> </thead> <tbody> <c:forEach items="${dataList}" var="item" varStatus="index"> <tr> <td align="center">${item.xm}</td> <td align="center"><vsc:codeList codeType="sex" key="${item.xb}"/></td> <td align="center"><vsc:codeList codeType="IDType" key="${item.zjlx}"/></td> <td align="center">${item.zjhm}</td> <td align="center"><fmt:formatDate value='${item.csrq}' pattern='yyyy-MM-dd' /></td> <td align="center"><vsc:codeList codeType="shanghaiArea" key="${item.djqx}"/></td> <td align="center"><vsc:codeList codeType="enrollmentWill" key="${item.gbxxjdyy}"/></td> <td align="center"><vsc:codeList codeType="rylx" key="${item.rylx}"/></td> <td align="center">${item.xxmc}</td> <td align="center"><vsc:codeList codeType="zyxz" key="${item.zyxz }"/></td> <td align="center"><fmt:formatDate value='${item.dxfssj}' pattern='yyyy-MM-dd' /></td> <td align="center">${item.jhrsjhm}</td> </tr> </c:forEach> </tbody> </table> 在这个页面加一个sheet,该如何操作呢,萌新求指教

将x-www-form-urlencoded解码为数组

<div class="post-text" itemprop="text"> <p>I'm trying to transform PUT request params to a key=&gt;value array in my server.</p> <pre><code>parse_str(file_get_contents('php://input'), $data); </code></pre> <p>This way I get a "dirt" array like this:</p> <pre><code>Array ( [------WebKitFormBoundaryXXXXXXXXXXXXXXXX Content-Disposition:_form-data;_name] =&gt; "birth_date" 1995-01-03 ------WebKitFormBoundaryXXXXXXXX Content-Disposition: form-data; name="age" 15 ------WebKitFormBoundaryXXXXXXXX-- ) </code></pre> <p>How can I extrapolate just the two key=&gt;values without manually parsing the content...?</p> </div>

如何解析Content-Disposition标头以检索filename属性?

<div class="post-text" itemprop="text"> <p>Using go, how can I parse the Content-Disposition header retrieved from an http HEAD request to obtain the filename of the file?</p> <p>Additionally, how do I retrieve the header itself from the http HEAD response? Is something like this correct?</p> <pre><code>resp, err := http.Head("http://example.com/") //handle error contentDisposition := resp.Header.Get("Content-Disposition") </code></pre> <p>The <code>mime/multipart</code> package specifies a method on the Part type that returns the filename (called FileName), but it's not clear to me how I should construct a Part, or from what.</p> </div>

无法在php中发布FormData

<div class="post-text" itemprop="text"> <p>I'm trying to use posted FormData form an AJAX call in PHP, but I cannot retrieve the variables. What I'm doing wrong?</p> <p>here is my Javascript</p> <pre><code>var sendData = new FormData(); sendData.append('itemid',$('select#selectItems').val()); sendData.append('itemtitle',$('#item-title').val()); sendData.append('itemtext',$('#item-text').val()); $.ajax({ url: 'ajax.file.php', type: 'POST', dataType: 'text', data: sendData, cache: false, contentType: false, processData: false }); </code></pre> <p>and my PHP</p> <pre><code>$itemid = $_POST['itemid']; echo $itemid; </code></pre> <p>is always undefined in PHP!</p> <p>and if I print_r ($_POST);</p> <p>If I use Firefox the PHP text is:</p> <blockquote> <p>Array ( [-----------------------------12850217581176488271638880149 Content-Disposition:_form-data;_name] =&gt; "itemid" 99 -----------------------------12850217581176488271638880149 Content-Disposition: form-data; name="itemtitle" The Title -----------------------------12850217581176488271638880149 Content-Disposition: form-data; name="itemtext" The Text -----------------------------12850217581176488271638880149-- ) </p> </blockquote> <p>...and using Chrome the PHP response is:</p> <blockquote> <p>Array ( [------WebKitFormBoundarypyFlwBB31gVYXxRP Content-Disposition:_form-data;_name] =&gt; "itemid" 99 ------WebKitFormBoundarypyFlwBB31gVYXxRP Content-Disposition: form-data; name="itemtitle" The Title ------WebKitFormBoundarypyFlwBB31gVYXxRP Content-Disposition: form-data; name="itemtext" The Text ------WebKitFormBoundarypyFlwBB31gVYXxRP-- )</p> </blockquote> <p>thanks</p> </div>

通过multipart/form-data ,python+post上传excel文档

Content-Disposition: form-data; name="distributeDetailFile"; filename="test.xlsx" Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet Content-Disposition: form-data; name="name" TRT -----------------------------148644891810696992751850105888 Content-Disposition: form-data; name="type" 10 -----------------------------148644891810696992751850105888 Content-Disposition: form-data; name="assetCode" zsc -----------------------------148644891810696992751850105888--

使用Content-disposition查看文件内容:使用套接字附件

<div class="post-text" itemprop="text"> <p>I want to parse the contents of a dynamic .csv file. However, this code (obviously with duff file names, etc.):</p> <pre><code>$socket = fsockopen("www.example.com", 443); fwrite($socket, "GET /dynamicCsv.csv?param=value HTTP/1.1 "); fwrite($socket, "Host: www.example.com "); fwrite($socket, "Connection: close "); fwrite($socket, " "); while(!feof($socket)) echo fgets($socket); </code></pre> <p>...just downloads the file.</p> <p>Using openssl at command line I can type the exact same request and get the following response header sent back:</p> <pre><code>HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Content-disposition: attachment; filename=dynamicCsv.csv Pragma: public Cache-Control: max-age=0 Set-Cookie: SESSIONID=ASDFUHN023UIN0F; Path=/; Secure Content-Type: text/csv;charset=UTF-8 Transfer-Encoding: chunked Date: Thu, 04 Feb 2010 16:53:00 GMT </code></pre> <p>To avoid having the file download automatically I have tried to chop off the first character using <code>substr</code>, in the hope that maybe the browser sees the response output by <code>fgets</code> as a set of headers of the current document. That didn't work. Pursuing the same idea I also tried to insert a bunch of newlines before opening the socket, which didn't work either.</p> <p>My two questions are:</p> <ol> <li>Why on earth does the browser think it should download the file?</li> <li>How can I stop it?</li> </ol> <p>I should mention that I've only used Chrome so far, but I don't see why it would make a difference.</p> <p>Many thanks, Andreas</p> </div>

在PHP中为CURL Post构建一个数组

<div class="post-text" itemprop="text"> <p>How do you build an array for a curl post in php without overwriting the previous field? The headers show me the following in the post:</p> <pre><code>Content-Disposition: form-data; name="price[][unit]" One -----------------------------122371200014463 Content-Disposition: form-data; name="price[][price]" 50 -----------------------------122371200014463 Content-Disposition: form-data; name="price[][unit]" Two -----------------------------122371200014463 Content-Disposition: form-data; name="price[][price]" 95 -----------------------------122371200014463 Content-Disposition: form-data; name="price[][unit]" Three -----------------------------122371200014463 Content-Disposition: form-data; name="price[][price]" 140 </code></pre> <p>I keep overwriting the previous item when I try to build the array like this:</p> <pre><code>$postPrice['price[][unit]'] = 'One'; $postPrice['price[][price]'] = $one; $postPrice['price[][unit]'] = 'Two'; $postPrice['price[][price]'] = $two; $postPrice['price[][unit]'] = 'Three'; $postPrice['price[][price]'] = $three; </code></pre> </div>

为什么有些代码不会在标题(“Content-disposition:...”)行之后运行?

<div class="post-text" itemprop="text"> <p>I was wondering if anyone know why the code after the <code>header(Content-disposition: ...)</code> will not run? It writes and downloads the file, but it will not run the <code>unlink()</code> line...</p> <p>This code is within a few other if statements originally.</p> <p>Here is the code:</p> <pre><code>$form1Array = array($_POST["namn"], $_POST["stad"]); $form1String = serialize($form1Array); $form1Fil = $_POST["namn"].".txt"; $midMappe = "midlertidig\\"; $fo_form1Fil = fopen($midMappe.$form1Fil, "w"); // if (fwrite($fo_form1Fil, $form1String)) { ignore_user_abort(true); // header("Content-type: text/plain"); header("Content-disposition: attachment; filename=".$form1Fil); // unlink($midMappe.$form1Fil); } else { echo "Could not save the file for download."; } </code></pre> <p>Thank you. :)</p> </div>

在PHP的curl中指定multipart / form-data的每个部分的Content-Type

<div class="post-text" itemprop="text"> <p>How do I specify the content type of a specific part of a multipart/form-data request? The content type for the image is being sent as <code>application/octet-stream</code>, however the server is expecting it to be <code>image/jpeg</code>. This causes the server to deny my request.</p> <pre><code>$data["file"] = "@/image.jpg"; $data["title"] = "The title"; $data["description"] = "The description"; //make the POST request $curl = curl_init(); curl_setopt($curl, CURLOPT_URL,$url); curl_setopt($curl, CURLOPT_VERBOSE, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, $header); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); $result = curl_exec($curl); </code></pre> <p>This is the relevant parts of the request:</p> <pre><code>Content-Type: multipart/form-data; boundary=----------------------------fc57f743c490 ------------------------------fc57f743c490 Content-Disposition: form-data; name="file"; filename="NASA-23.jpg" Content-Type: application/octet-stream </code></pre> <p>I want it to be:</p> <pre><code>Content-Type: multipart/form-data; boundary=----------------------------fc57f743c490 ------------------------------fc57f743c490 Content-Disposition: form-data; name="file"; filename="NASA-23.jpg" Content-Type: image/jpeg </code></pre> </div>

如何从我的Android应用程序上传表单数据和多个文件,使用HTTPURLConnection到我的服务器,我在哪里使用PHP?

<div class="post-text" itemprop="text"> <p>I have an android application that is sending 1 or more zip files to the server. I'd like to send some additional form data along with the files, because the form data will be used to determine the disposition of the files.</p> <p>I've been able to upload the files using multi-part as a content-type, but I can't seem to get the php on the server side to see both form data and the files.</p> <p>What I'd like to know is how to send form data and a list of files to the server using HTTPUrlConnection on the android side and PHP on the server side.</p> <p>I believe my problem is related to Content-Type and Content-Disposition. I'd really appreciate it if someone could point me at a definitive example, or explain what I'm doing wrong.</p> <p>Thanks for taking the time to look at this problem.'</p> <p>Here's the latest, revised android code:</p> <pre><code>String postDriverUpload(File[] fileList) { HttpURLConnection connection = null; DataOutputStream outputStream = null; String tag = TAG + "postDriverInfo()"; URL url = null; String result = OK_TO_CONTINUE; String targetUrl = server + "/upload.php"; try { url = new URL(targetUrl); } catch (MalformedURLException e) { result = "ERROR: [" + targetUrl + "] can't be parsed into a URL."; Log.e(tag, result, e); return result; } try { connection = (HttpURLConnection) url.openConnection(); } catch (IOException e) { result = "ERROR: IOException."; Log.e(tag, result, e); return result; } // Allow Inputs and Outputs connection.setDoInput(true); connection.setDoOutput(true); connection.setUseCaches(false); // Enable POST method try { connection.setRequestMethod("POST"); } catch (ProtocolException e) { result = "Error: Protocol Exception."; Log.e(tag, result, e); return result; } connection.setRequestProperty("Connection", "Keep-Alive"); connection.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + BOUNDARY); // Encode driver userName List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(); try { nameValuePairs.add(new BasicNameValuePair("userName", driver .getUserName())); Log.d(tag, "Encoded userName='driver' is: " + encodeData(nameValuePairs)); // Create output Stream to send data to server outputStream = new DataOutputStream(connection.getOutputStream()); writeBoundary(outputStream); outputStream .writeBytes("Content-Disposition: form-data; name=\"userName\" " + EOL + EOL); outputStream.writeBytes(driver.getUserName() + EOL); writeBoundary(outputStream); // Starting the Files part outputStream .writeBytes("Content-Disposition: form-data; name=\"files\" " + EOL + EOL); outputStream.writeBytes("Content-Type: multipart/mixed; boundary=" + FILE_BOUNDARY + EOL); // Adding the file parts for (File file : fileList) { writeFileBoundary(outputStream); // write out file String contentType = String.format( "Content-Disposition:file; filename=\"%s\"" + EOL + "Content-Type: application/x-zip-compressed", file.getName()) + EOL + EOL; Log.d(tag, "Content-Type = " + contentType); outputStream.write(contentType.getBytes()); } writeFileBoundary(outputStream); writeBoundary(outputStream); outputStream.flush(); outputStream.close(); } catch (UnsupportedEncodingException e) { result = "Error: UnsupportedEncodingException "; Log.e(tag, result, e); return result; } catch (IOException e) { result = "Error: IOException "; Log.e(tag, result, e); return result; } // Get Response from server (code and message) try { int serverResponseCode = connection.getResponseCode(); String serverResponseMessage = connection.getResponseMessage(); Log.d(tag, "Response Code = " + serverResponseCode); Log.d(tag, "Response Message = " + serverResponseMessage); } catch (IOException e) { result = "Error getting response from server."; Log.e(tag, result, e); return result; } final StringBuilder out = new StringBuilder(); try { BufferedReader in = new BufferedReader(new InputStreamReader( connection.getInputStream())); String line; while (null != (line = in.readLine())) { if (line.contains("ERROR")) { Log.d(tag, "HTTPResponse: " + out.toString()); result = "Error: HTTPResponse: " + out.toString(); break; } out.append(line + " "); } Log.d(tag, "HTTPResponse: " + out.toString()); } catch (IOException e) { Log.w(tag, "WARNING: ", e); } return result; } void writeBoundary(DataOutputStream out) throws IOException { final String twoHyphens = "--"; out.writeBytes(twoHyphens + BOUNDARY + EOL); } void writeFileBoundary(DataOutputStream out) throws IOException { final String twoHyphens = "--"; out.writeBytes(twoHyphens + FILE_BOUNDARY + EOL); } </code></pre> <p>Here's the output of my logging on the Android side. As you can see, the key, userName and value, rbenjamin, are being properly loaded into the $_POST variable, but something isn't right past that point. I delimit the next section with the BOUNDARY, but it seems to be gobbled up into the value for the variable 'files'. I'm close, but I'm still missing something. (I stripped out most of the noise in the log file below.)</p> <pre><code>: Upload Button Clicked. : Compiling upload file : getting delivered SQL = SELECT * FROM deliveryorder WHERE delivereddatetime != '' : uploadEnabled = true : downloadEnabled = false : driverEmail = ray.benjamin@gmail.com : Starting, getting database. : Found 1 drivers. : Processing driver 1 : user name is rbenjamin : email is ray.benjamin@gmail.com : Uploading files using HTTP to http://192.168.1.17:8080 : There are 16 files. : Checking download - enabled? false : Encoded userName='driver' is: userName=rbenjamin : Content-Type = Content-Disposition:file; filename="upload20130820_1015.zip" : Content-Type: application/x-zip-compressed : : Content-Type = Content-Disposition:file; filename="upload20130820_1048.zip" : Content-Type: application/x-zip-compressed : : Content-Type = Content-Disposition:file; filename="upload20130821_1624.zip" : Content-Type: application/x-zip-compressed : : Content-Type = Content-Disposition:file; filename="upload20130821_1628.zip" : Content-Type: application/x-zip-compressed : : Content-Type = Content-Disposition:file; filename="upload20130821_1645.zip" : Content-Type: application/x-zip-compressed : : Content-Type = Content-Disposition:file; filename="upload20130821_1647.zip" : Content-Type: application/x-zip-compressed : : Content-Type = Content-Disposition:file; filename="upload20130821_1705.zip" : Content-Type: application/x-zip-compressed : : Content-Type = Content-Disposition:file; filename="upload20130821_1709.zip" : Content-Type: application/x-zip-compressed : : Content-Type = Content-Disposition:file; filename="upload20130821_1746.zip" : Content-Type: application/x-zip-compressed : : Content-Type = Content-Disposition:file; filename="upload20130821_1801.zip" : Content-Type: application/x-zip-compressed : : Content-Type = Content-Disposition:file; filename="upload20130821_1804.zip" : Content-Type: application/x-zip-compressed : : Content-Type = Content-Disposition:file; filename="upload20130821_1811.zip" : Content-Type: application/x-zip-compressed : : Content-Type = Content-Disposition:file; filename="upload20130821_1813.zip" : Content-Type: application/x-zip-compressed : : Content-Type = Content-Disposition:file; filename="upload20130821_1821.zip" : Content-Type: application/x-zip-compressed : : Content-Type = Content-Disposition:file; filename="upload20130821_2050.zip" : Content-Type: application/x-zip-compressed : : Content-Type = Content-Disposition:file; filename="upload20130825_1957.zip" : Content-Type: application/x-zip-compressed : : Response Code = 200 : Response Message = OK : HTTPResponse: &lt;!DOCTYPE html&gt; : &lt;html&gt; : &lt;body&gt; : POST is defined.&lt;br&gt;Key = userName"_, Value = rbenjamin&lt;br&gt;Key = files"_, Value = Content-Type: multipart/mixed; boundary=**FILE*BOUNDARY***25WLqf@*** : --**FILE*BOUNDARY***25WLqf@*** : Content-Disposition:file; filename="upload20130820_1015.zip" : Content-Type: application/x-zip-compressed : --**FILE*BOUNDARY***25WLqf@*** : Content-Disposition:file; filename="upload20130820_1048.zip" : Content-Type: application/x-zip-compressed : --**FILE*BOUNDARY***25WLqf@*** : Content-Disposition:file; filename="upload20130821_1624.zip" : Content-Type: application/x-zip-compressed : --**FILE*BOUNDARY***25WLqf@*** : Content-Disposition:file; filename="upload20130821_1628.zip" : Content-Type: application/x-zip-compressed : --**FILE*BOUNDARY***25WLqf@*** : Content-Disposition:file; filename="upload20130821_1645.zip" : Content-Type: application/x-zip-compressed : --**FILE*BOUNDARY***25WLqf@*** : Content-Disposition:file; filename="upload20130821_1647.zip" : Content-Type: application/x-zip-compressed : --**FILE*BOUNDARY***25WLqf@*** : Content-Disposition:file; filename="upload20130821_1705.zip" : Content-Type: application/x-zip-compressed : --**FILE*BOUNDARY***25WLqf@*** : Content-Disposition:file; filename="upload20130821_1709.zip" : Content-Type: application/x-zip-compressed : --**FILE*BOUNDARY***25WLqf@*** : Content-Disposition:file; filename="upload20130821_1746.zip" : Content-Type: application/x-zip-compressed : --**FILE*BOUNDARY***25WLqf@*** : Content-Disposition:file; filename="upload20130821_1801.zip" : Content-Type: application/x-zip-compressed : --**FILE*BOUNDARY***25WLqf@*** : Content-Disposition:file; filename="upload20130821_1804.zip" : Content-Type: application/x-zip-compressed : --**FILE*BOUNDARY***25WLqf@*** : Content-Disposition:file; filename="upload20130821_1811.zip" : Content-Type: application/x-zip-compressed : --**FILE*BOUNDARY***25WLqf@*** : Content-Disposition:file; filename="upload20130821_1813.zip" : Content-Type: application/x-zip-compressed : --**FILE*BOUNDARY***25WLqf@*** : Content-Disposition:file; filename="upload20130821_1821.zip" : Content-Type: application/x-zip-compressed : --**FILE*BOUNDARY***25WLqf@*** : Content-Disposition:file; filename="upload20130821_2050.zip" : Content-Type: application/x-zip-compressed : --**FILE*BOUNDARY***25WLqf@*** : Content-Disposition:file; filename="upload20130825_1957.zip" : Content-Type: application/x-zip-compressed : --**FILE*BOUNDARY***25WLqf@***&lt;br&gt; : Notice: Undefined index: userName in /var/www-pbs/upload.php on line 15 : Call Stack: : 0.0083 638888 1. {main}() /var/www-pbs/upload.php:0 : User Name is: &lt;br&gt;FILES is defined.&lt;br&gt; : Notice: Undefined index: file in /var/www-pbs/upload.php on line 24 : Call Stack: : 0.0083 638888 1. {main}() /var/www-pbs/upload.php:0 : &lt;p&gt;Dumping _FILES&lt;/p&gt; : Notice: Undefined index: file in /var/www-pbs/upload.php on line 34 : Call Stack: : 0.0083 638888 1. {main}() /var/www-pbs/upload.php:0 : Notice: Undefined index: file in /var/www-pbs/upload.php on line 40 : Call Stack: : 0.0083 638888 1. {main}() /var/www-pbs/upload.php:0 : Upload: &lt;br&gt; : Notice: Undefined index: file in /var/www-pbs/upload.php on line 41 : Call Stack: : 0.0083 638888 1. {main}() /var/www-pbs/upload.php:0 : Type : &lt;br&gt; : Notice: Undefined index: file in /var/www-pbs/upload.php on line 42 : Call Stack: : 0.0083 638888 1. {main}() /var/www-pbs/upload.php:0 : Size : 0 kB&lt;br&gt; : Notice: Undefined index: file in /var/www-pbs/upload.php on line 43 : Call Stack: : 0.0083 638888 1. {main}() /var/www-pbs/upload.php:0 : Stored in: : Notice: Undefined index: file in /var/www-pbs/upload.php on line 45 : Call Stack: : 0.0083 638888 1. {main}() /var/www-pbs/upload.php:0 : Notice: Undefined index: file in /var/www-pbs/upload.php on line 47 : Call Stack: : 0.0083 638888 1. {main}() /var/www-pbs/upload.php:0 : already exists. : &lt;/body&gt; : &lt;/html&gt; : 200 </code></pre> </div>

使用curl php发布标题

<div class="post-text" itemprop="text"> <p>when I post the reply in a forum, I use live http header to view parameter which used to post the reply. but, the headers no parameter. but, there are some header like this:</p> <pre><code>Content-Length: 1115 -----------------------------5959623329472 Content-Disposition: form-data; name="subject" the title of reply -----------------------------5959623329472 Content-Disposition: form-data; name="message" the content of reply </code></pre> <p>how to post the headers with curl ? my code don't work</p> <pre><code>curl_setopt($ch, CURLOPT_HTTPHEADER, array('POST /post HTTP/1.1', 'Referer: http://*****.n-stars.org/post?t=4221&amp;mode=reply', 'Content-Disposition: form-data; name="subject" test lagi kk 2', 'Content-Disposition: form-data; name="message" test lagi ya kk 8)' )); </code></pre> <p>please help me :D</p> </div>

使用Content-Disposition:并行附件发送文件

<div class="post-text" itemprop="text"> <p>I have a PHP page that sends a file to the browser depending on the request data it receives. getfile.php?get=something sends file A, getfile.php?get=somethingelse sends file B and so on and so forth. This is done like so:</p> <pre><code>header('Content-Disposition: attachment; filename='. urlencode($filename)); readfile($fileURL); </code></pre> <p>It works except it can only send one file at a time. Any other files requested are send in linear fashion. One starts as soon as another finishes. </p> <p>How can I get this to send files in parallel if the user requests another file while one is downloading?</p> <p>Edit: I have tried downloading two files at the same time by directly using their filepaths and it works, so neither Apache, nor the browser seem to have a problem. It seems PHP is the issue. I have by the way used session_start() at the beginning of the page.</p> </div>

将Content-Disposition标头配置为附件时,不会触发iframe的load事件

<div class="post-text" itemprop="text"> <p>First of all i just want the 'load' event to be fired only in Mozilla Firefox.</p> <p>I've already tried different ways, but all i came to know is that load event of an ifrmae will only gets fired while the 'Content-Disposition' header is configured as 'inline'.</p> <p>Is there any other event by which i came to know that the iframe dialog box pops up and ask user to save the file?</p> <p>Please have look into the following implementation of mine and help me to get the proper solution.</p> <p>HTML code : </p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript" src="FileName.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;input type = "button" value="Download" onclick = "javascript:downloadFile('http://localhost/data.php');"&gt;&lt;/input&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Javascript code :</p> <pre><code>var downloadFile = function(url) { // create hidden iframe var id = "xyz"; var frame = document.createElement('iframe'); frame.id = id; frame.name = id; frame.style="visibility:hidden;display:none"; document.body.appendChild(frame); var callback = function() { alert('completed'); }; frame.onload = callback; frame.src = url; }; </code></pre> <p>PHP code : </p><pre><code>// Set Content Disposition header header('Content-Disposition: attachment; filename=some.txt'); // Set content type header header('Content-Type: application/octet-stream'); $file = "some.txt"; if(!file_exists($file)) die("I'm sorry, the file doesn't seem to exist."); header('Pragma: no-cache'); header('Expires: 0'); readfile($file); ?&gt; </code></pre> <p>Thanking you in advance. Hoping for a proper solution.</p> </div>

从Location标头转换为Content-Disposition标头,以消除浏览器警告

<div class="post-text" itemprop="text"> <p>Until now I used Location header for downloading files from my website. It was giving in Chrome</p> <p><em>This file could be dangerous | Discard</em> message. (At least on Windows.)</p> <p>I have the very same files hosted on many software websites and nowhere it gives such a warning. That is why I looked around for a solution.</p> <p>On <a href="http://www.webconfs.com/http-header-check.php" rel="nofollow">Header Test</a> I get this</p> <pre><code>HTTP/1.1 200 OK =&gt; Server =&gt; nginx Date =&gt; Sun, 24 Apr 2016 10:24:19 GMT Content-Type =&gt; application/zip Content-Length =&gt; 10635840 Connection =&gt; close Set-Cookie =&gt; lng=en; expires=Mon, 24-Apr-2017 10:24:19 GMT; Max-Age=31536000; path=/; domain=www.vlastimilburian.cz Accept-Ranges =&gt; bytes Content-Disposition =&gt; attachment; filename="extreme_password_generator.zip" Content-Language =&gt; cs </code></pre> <p>And after I set the headers in this download script</p> <p><a href="https://www.vlastimilburian.cz/download.php?pid=12&amp;portable" rel="nofollow">https://www.vlastimilburian.cz/download.php?pid=12&amp;portable</a></p> <p>I run the following:</p> <pre><code>$fn = fopen($product_object-&gt;get_file_name(), "r"); fpassthru($fn); </code></pre> <p>Which is completely different solution than using Location header. Yet so far no success.</p> <p>Am I on the right track? Or what do I miss?</p> </div>

在Laravel 5.1中,当我发送标题Content-type来下载文件时,我是否必须将die()放在最后?

<div class="post-text" itemprop="text"> <p>This is my helper</p> <pre><code>function fileDownload(EloquentFile $file, bool $stream): bool { $file_dir = $file-&gt;dir . '/'; $file_url = $file_dir . $file-&gt;id; $stream = $stream === true ? 'attachment' : 'inline'; if (Storage::disk('s3')-&gt;has($file_url)) { header('Content-type: ' . $file-&gt;mime); header('Content-Disposition: ' . $stream . '; filename=' . $file-&gt;name); header('Content-Length: ' . $file-&gt;size); echo Storage::disk('s3')-&gt;get($file_url); //die(); do I have to put die here? } abort(404); } </code></pre> <p>Question - does commented <code>die()</code> is required here or can I skip it?</p> </div>

“Content-Type:text / plain”强制下载文件

<div class="post-text" itemprop="text"> <p>If I call <code>header('Content-Type:text/plain; charset=ISO-8859-15');</code> the browser will download the file instead of showing it. Using <code>text/html</code> works instead. (the downloaded file is processed anyway, it's not downloading the source code)</p> <p>I've tried to add <code>header('Content-Disposition:inline;');</code> but it was just ignored.</p> <p>I'm pretty clueless about what could cause this problem, any tip?</p> <p>The server is MAMP 1.9.6 (PHP 5.3.5, Apache/2.0.64).</p> <p>edit: this only happens on Chrome, it works on Firefox, Camino and Safari.</p> </div>

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

我说我不会算法,阿里把我挂了。

不说了,字节跳动也反手把我挂了。

抖音上很火的时钟效果

反正,我的抖音没人看,别人都有几十万个赞什么的。 发到CSDN上来,大家交流下~ 主要用到原生态的 JS+CSS3。 具体不解释了,看注释: &lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;title&gt;Title&lt;/tit...

记录下入职中软一个月(外包华为)

我在年前从上一家公司离职,没想到过年期间疫情爆发,我也被困在家里,在家呆着的日子让人很焦躁,于是我疯狂的投简历,看面试题,希望可以进大公司去看看。 我也有幸面试了我觉得还挺大的公司的(虽然不是bat之类的大厂,但是作为一名二本计算机专业刚毕业的大学生bat那些大厂我连投简历的勇气都没有),最后选择了中软,我知道这是一家外包公司,待遇各方面甚至不如我的上一家公司,但是对我而言这可是外包华为,能...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

手机经常收到"回复TD退订",回还是不回?今天总算是弄清楚了

自从有了微信和QQ,手机短信几乎很少再用了,但是我们手机里面还是经常会收到"回复TD退订"的消息,那到底要不要回复呢?今天就来告诉大家! 信息内容可能包括 推销信息 品牌活动日的时候,会根据你的用户浏览信息,或者购买记录,后续发送一些降价消息。 但是笔者想说我是缺那10块钱的人嘛,我缺的是1000块。 垃圾信息 虽然我们已经不经常用短信功能,但是还是有不少...

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试官问我:如何加载100M的图片却不撑爆内存

还记得当年面试一个面试官问我怎么加载巨图才能不撑爆内存,我没回答上来,他说分片显示,我寻思特么分片能减少内存使用??现在可以打他脸了! 内容扩展 1.图片的三级缓存中,图片加载到内存中,如果内存快爆了,会发生什么?怎么处理? 2.内存中如果加载一张 500*500 的 png 高清图片.应该是占用多少的内存? 3.Bitmap 如何处理大图,如一张 30M 的大图,如何预防 OOM? A...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

又出事了?网站被攻击了?高中生?

北京时间2020年3月27日9点整,如往常一样来到公司,带开电脑,正准备打开Github网站看一会源代码,再开始手头的工作。哟吼,一直打不开,一直出现如下页面: 我想很多网友也尝到了甜头,各大技术群炸开了锅,据网友反馈有攻击者正在发起大规模的中间人挟持,京东和Github等网站等网站都受到了影响。 什么是中间中间人挟持呢? 简而言之,就是攻击者在数据网络传输的过程中,截获传输过程中的数据并篡改...

无代码时代来临,程序员如何保住饭碗?

编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

培训班出来的人后来都怎么样了?(二)

接着上回说,培训班学习生涯结束了。后面每天就是无休止的背面试题,不是没有头脑的背,培训公司还是有方法的,现在回想当时背的面试题好像都用上了,也被问到了。回头找找面试题,当时都是打印下来天天看,天天背。 不理解呢也要背,面试造飞机,上班拧螺丝。班里的同学开始四处投简历面试了,很快就有面试成功的,刚开始一个,然后越来越多。不知道是什么原因,尝到胜利果实的童鞋,不满足于自己通过的公司,嫌薪水要少了,选择...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

6年开发经验女程序员,面试京东Java岗要求薪资28K

写在开头: 上周面试了一位女程序员,上午10::30来我们部门面试,2B哥接待了她.来看看她的简历: 个人简历 个人技能: ● 熟悉spring mvc 、spring、mybatis 等框架 ● 熟悉 redis 、rocketmq、dubbo、zookeeper、netty 、nginx、tomcat、mysql。 ● 阅读过juc 中的线程池、锁的源...

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

工作八年,月薪60K,裸辞两个月,投简历投到怀疑人生!

近日,有网友在某职场社交平台吐槽,自己裸辞两个月了,但是找工作却让自己的心态都要崩溃了,全部无果,不是已查看无回音,就是已查看不符合。 “工作八年,两年一跳,裸辞两个月了,之前月薪60K,最近找工作找的心态崩了!所有招聘工具都用了,全部无果,不是已查看无回音,就是已查看不符合。进头条,滴滴之类的大厂很难吗???!!!投简历投的开始怀疑人生了!希望 可以收到大厂offer” 先来看看网...

推荐9个能让你看一天的网站

分享的这9个保证另你意外的网站,每个都非常实用!非常干货!毫不客气的说,这些网站最少值10万块钱。 利用好这些网站,会让你各方面的技能都得到成长,不说让你走上人生巅峰,但对比现在的你,在眼界、学识、技能方面都有质的飞跃。 一、AIRPANO 传送门:https://www.airpano.com/360photo_list.php 这是一个可以躺在家里,就能环游世界的神奇网站。 世界那么大,绝大多...

大牛都会用的IDEA调试技巧!!!

导读 前天面试了一个985高校的实习生,问了他平时用什么开发工具,他想也没想的说IDEA,于是我抛砖引玉的问了一下IDEA的调试用过吧,你说说怎么设置断点...

都前后端分离了,咱就别做页面跳转了!统统 JSON 交互

文章目录1. 无状态登录1.1 什么是有状态1.2 什么是无状态1.3 如何实现无状态1.4 各自优缺点2. 登录交互2.1 前后端分离的数据交互2.2 登录成功2.3 登录失败3. 未认证处理方案4. 注销登录 这是本系列的第四篇,有小伙伴找不到之前文章,松哥给大家列一个索引出来: 挖一个大坑,Spring Security 开搞! 松哥手把手带你入门 Spring Security,别再问密...

月薪22K程序员,打卡迟到10次,收到工资短信一脸懵逼

每家公司为了保证公司员工每天的工作时间,一般都会采用上下班打卡的工作制度,这其实是一个很常见的是,本身也没有什么问题的。正所谓无规矩不成方圆,公司肯定是有公司的规矩,虽然每个员工都很不喜欢这些规矩来束缚我们,但是公司也只是为了能更好的管理员工。但是一家公司如果一成不变的使用打卡制度,而不会去变通管理,也真不一定是好事。 打卡制度特别对于销售部门来说,不但会让公司发展不起来,还很容易丢失员工。但如...

97年世界黑客编程大赛冠军作品(大小仅为16KB),惊艳世界的编程巨作

这是世界编程大赛第一名作品(97年Mekka ’97 4K Intro比赛)汇编语言所写。 整个文件只有4095个字节, 大小仅仅为16KB! 不仅实现了3D动画的效果!还有一段震撼人心的背景音乐!!! 内容无法以言语形容,实在太强大! 下面是代码,具体操作看最后! @echo off more +1 %~s0|debug e100 33 f6 bf 0 20 b5 10 f3 a5...

不要再到处使用 === 了

我们知道现在的开发人员都使用 === 来代替 ==,为什么呢?我在网上看到的大多数教程都认为,要预测 JavaScript 强制转换是如何工作这太复杂了,因此建议总是使用===。这些都...

什么是a站、b站、c站、d站、e站、f站、g站、h站、i站、j站、k站、l站、m站、n站?00后的世界我不懂!

A站 AcFun弹幕视频网,简称“A站”,成立于2007年6月,取意于Anime Comic Fun,是中国大陆第一家弹幕视频网站。A站以视频为载体,逐步发展出基于原生内容二次创作的完整生态,拥有高质量互动弹幕,是中国弹幕文化的发源地;拥有大量超粘性的用户群体,产生输出了金坷垃、鬼畜全明星、我的滑板鞋、小苹果等大量网络流行文化,也是中国二次元文化的发源地。 B站 全称“哔哩哔哩(bilibili...

十个摸鱼,哦,不对,是炫酷(可以玩一整天)的网站!!!

文章目录前言正文**1、Kaspersky Cyberthreat real-time map****2、Finding Home****3、Silk – Interactive Generative Art****4、Liquid Particles 3D****5、WINDOWS93****6、Staggering Beauty****7、Ostagram图片生成器网址****8、全历史网址*...

我真的错了,我被跳槽后的高薪冲昏了头脑...

国内疫情已接近尾声,疫情对生活各个方面造成的影响,就是一场真实的“蝴蝶效应”。“全球最大安全套制造商因疫情停产,已造成一亿个安全套缺口”“口罩印钞机,月入千万的暴富神话”“百程旅行...

终于,月薪过5万了!

来看几个问题想不想月薪超过5万?想不想进入公司架构组?想不想成为项目组的负责人?想不想成为spring的高手,超越99%的对手?那么本文内容是你必须要掌握的。本文主要详解bean的生命...

​能让德国人放弃现金支付​,也没谁了

在新冠疫情中,德国人越来越多地选择在超市,加油站或其他商店付款时使用非接触式付款方式。德国信贷协会Deutschen Kreditwirtschaft (DK) 的一位发言人告诉德国新...

相关热词 c# 按行txt c#怎么扫条形码 c#打包html c# 实现刷新数据 c# 两个自定义控件重叠 c#浮点类型计算 c#.net 中文乱码 c# 时间排序 c# 必备书籍 c#异步网络通信
立即提问