本文介绍了使用表单发布从客户端获取文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 是否可以在不使用表单的情况下获取文件? 我想获取文件,文本或二进制文件的数据(字节),并且只是 将其保存到变量中。类似于在其中包含 文件输入元素的表单的帖子主体。 最终我想做的是从客户端机器上获取文件(他们指定了)并使用标准的发布请求将其发送到服务器。 这与带有文件输入元素的表单帖子完全相同, 但我不想使用表单,我想获取文件数据和 先操作它然后发回。所以,问题是,如何在不使用表单的情况下从客户端获取文件?b 任何指针都会被赞赏。Is it possible to get a file without using a form post?I want to get the data (bytes) of a file, text or binary, and justsave it to a variable. Similar to the post body of a form that has afile input element in it.Ultimately what I want to do is get a file off client machine (thatthey specify) and send it to the server using a standard post request.This is exactly the same as a form post with an file input element,but I don''t want to use a form, I want to get the file data andmanipulate it first then post it back. So, the problem is, how can Iget the file from the client without using a form? Any pointers wouldbe appreciated.推荐答案 我创建一个字符串,其中包含经过验证的表单输入数据,用 分隔一些特殊字符。与cookie值相同。您可以将它保存为作为日志条目,文件,长期cookie,无论您喜欢什么。I create a string comprising the validated form input data separated withsome special character. Same as a cookie value is crafted. You can save itas a log entry, a file, a long-term cookie, whatever your pleasure. 加载表单时,获取''encoded''值,将其拆分为特殊的 字符,形成一个包含原始表单数据,并使用 数组数据填写表格。 - Ed Jay(删除''M''通过电子邮件回复)On loading the form, fetch the ''encoded'' value, split it at the specialcharacter to form an array comprising the original form data, and use thearray data to fill in the form.--Ed Jay (remove ''M'' to respond by email) 我创建一个字符串,其中包含经过验证的表单输入数据,用 分隔一些特殊字符。与cookie值相同。您可以将它保存为作为日志条目,文件,长期cookie,无论您喜欢什么。I create a string comprising the validated form input data separated withsome special character. Same as a cookie value is crafted. You can save itas a log entry, a file, a long-term cookie, whatever your pleasure. 加载表单时,获取''encoded''值,将其拆分为特殊的 字符,形成一个包含原始表单数据,并使用 数组数据填写表格。 - Ed Jay(删除''M''通过电子邮件回复)On loading the form, fetch the ''encoded'' value, split it at the specialcharacter to form an array comprising the original form data, and use thearray data to fill in the form.--Ed Jay (remove ''M'' to respond by email) 我仍​​然感到困惑。你能具体说明如何用javascript获取File 输入数据吗?I''m still confused. Can you be move specific on how I can get the Fileinput data with javascript? 我创建一个字符串,其中包含用某些特殊字符分隔的经过验证的表单输入数据。与cookie值相同。您可以将它保存为日志条目,文件,长期cookie,无论您喜欢什么。 I create a string comprising the validated form input data separated withsome special character. Same as a cookie value is crafted. You can save itas a log entry, a file, a long-term cookie, whatever your pleasure. 在加载表单时,获取''encoded''值,将其拆分为特殊的字符,以形成包含原始表单数据的数组,并使用数组数据填写表格。 - Ed Jay(删除''M''通过电子邮件回复) On loading the form, fetch the ''encoded'' value, split it at the specialcharacter to form an array comprising the original form data, and use thearray data to fill in the form.--Ed Jay (remove ''M'' to respond by email) 我''我还是很困惑。你能具体说明如何使用javascript获取File 输入数据吗? I''m still confused. Can you be move specific on how I can get the Fileinput data with javascript? 单程: < form ... yadayada> <输入type =" text" id =" firstX" value =" X1"> < input type =" text" id =" secondX" value =" X2"> < input type ="复选框" id =" thirdX" value =" X3"> < / form> ;; < script type =" text / javascript> x1 = document.forms [" formname"]。elements [" firstX"]。value; x2 = document.forms [" formname"]。elements [" secondX"]。value; x3 = document.forms [" formname"]。elements [" thirdX"]。checked; myString = x1 +,,+ x2 +, + x3; < / script> - Ed Jay(删除''M''回复者电子邮件)One way:<form...yadayada><input type = "text" id = "firstX" value = "X1"><input type = "text" id = "secondX" value = "X2"><input type = "checkbox" id = "thirdX" value = "X3"></form>;<script type="text/javascript>x1 = document.forms["formname"].elements["firstX"].value;x2 = document.forms["formname"].elements["secondX"].value;x3 = document.forms["formname"].elements["thirdX"].checked;myString = x1 + ","+ x2 + "," + x3;</script>--Ed Jay (remove ''M'' to respond by email) 这篇关于使用表单发布从客户端获取文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-22 22:49
查看更多