由于嵌入式限制,我们在服务器端自定义处理文件上载.
Firefox浏览器中使用的HTML文件上传代码:
<html>
<body>
<form action="http:///192.168.1.1/upload.cgi" name="form_1" method="post" enctype="multipart/form-data" >
<input type="file" id="file" name="filename" content-type="application/octet-stream">
<input type="submit" name="mysubmit" value="Send">
</form>
<body>
</html>
Run Code Online (Sandbox Code Playgroud)
如果所选文件名为"fish.jpg",则服务器将其内容类型称为"image/jpeg".如果文件被重命名为没有文件扩展名的"fish",则服务器将其内容类型作为"application/octet-stream"接收,这是我们想要的.
有没有办法在HTML页面中强制"application/octet-stream"(有或没有常规JavaScript)?
先谢谢,伯特