使用表单发布从客户端获取文件 [英] Getting file from client w/o using a form post

查看:65
本文介绍了使用表单发布从客户端获取文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在不使用表单的情况下获取文件?


我想获取文件,文本或二进制文件的数据(字节),并且只是

将其保存到变量中。类似于在其中包含

文件输入元素的表单的帖子主体。


最终我想做的是从客户端机器上获取文件(他们指定了
)并使用标准的发布请求将其发送到服务器。

这与带有文件输入元素的表单帖子完全相同,

但我不想使用表单,我想获取文件数据和

先操作它然后发回。所以,问题是,如何在不使用表单的情况下从客户端获取文件?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 just
save it to a variable. Similar to the post body of a form that has a
file input element in it.

Ultimately what I want to do is get a file off client machine (that
they 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 and
manipulate it first then post it back. So, the problem is, how can I
get the file from the client without using a form? Any pointers would
be appreciated.

推荐答案

例如**** @ gmail.com 写道:
eg****@gmail.com scribed:

>是否可以在不使用文件的情况下获取文件表单帖子?

我想获取文件,文本或二进制文件的数据(字节),然后将其保存到变量中。类似于在其中具有
文件输入元素的表单的帖子主体。
>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 just
save it to a variable. Similar to the post body of a form that has a
file input element in it.



我创建一个字符串,其中包含经过验证的表单输入数据,用

分隔一些特殊字符。与cookie值相同。您可以将它保存为
作为日志条目,文件,长期cookie,无论您喜欢什么。

I create a string comprising the validated form input data separated with
some special character. Same as a cookie value is crafted. You can save it
as a log entry, a file, a long-term cookie, whatever your pleasure.


>
最终我想做的是从客户端机器上获取文件(它们指定的)并将其发送到服务器使用标准的帖子请求。
这与带有文件输入元素的表单帖子完全相同,
但我不想使用表单,我想获取文件数据和<首先操纵它然后将其发回。所以,问题是,如何在不使用表单的情况下从客户端获取文件?任何指针都会受到赞赏。
>
Ultimately what I want to do is get a file off client machine (that
they 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 and
manipulate it first then post it back. So, the problem is, how can I
get the file from the client without using a form? Any pointers would
be appreciated.



加载表单时,获取''encoded''值,将其拆分为特殊的

字符,形成一个包含原始表单数据,并使用

数组数据填写表格。

-

Ed Jay(删除''M''通过电子邮件回复)

On loading the form, fetch the ''encoded'' value, split it at the special
character to form an array comprising the original form data, and use the
array data to fill in the form.
--
Ed Jay (remove ''M'' to respond by email)


2月24日晚上7:37,Ed Jay< e ... @ aes-intl.comwrote:
On Feb 24, 7:37 pm, Ed Jay <e...@aes-intl.comwrote:

egg ... @ gmail.com scribed:
egg...@gmail.com scribed:

是否可以在不使用表格的情况下获取文件?
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 just
save it to a variable. Similar to the post body of a form that has a
file input element in it.



我创建一个字符串,其中包含经过验证的表单输入数据,用

分隔一些特殊字符。与cookie值相同。您可以将它保存为
作为日志条目,文件,长期cookie,无论您喜欢什么。


I create a string comprising the validated form input data separated with
some special character. Same as a cookie value is crafted. You can save it
as a log entry, a file, a long-term cookie, whatever your pleasure.


最终我想要的是什么要做的是从客户端机器上获取一个文件(它们指定的是
)并使用标准的发布请求将其发送到服务器。

这与表单完全相同发布文件输入元素,

但我不想使用表单,我想获取文件数据和

先操作它然后发回。所以,问题是,如何在不使用表单的情况下从客户端获取文件?b
任何指针都会赞赏

Ultimately what I want to do is get a file off client machine (that
they 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 and
manipulate it first then post it back. So, the problem is, how can I
get the file from the client without using a form? Any pointers would
be appreciated.



加载表单时,获取''encoded''值,将其拆分为特殊的

字符,形成一个包含原始表单数据,并使用

数组数据填写表格。

-

Ed Jay(删除''M''通过电子邮件回复)


On loading the form, fetch the ''encoded'' value, split it at the special
character to form an array comprising the original form data, and use the
array 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 File
input data with javascript?


例如**** @ gmail.com 写道:
eg****@gmail.com scribed:

> 2月24日,7日:下午37点,Ed Jay< e ... @ aes-intl.comwrote:
>On Feb 24, 7:37 pm, Ed Jay <e...@aes-intl.comwrote:

> egg ... @ gmail.com scribed:
>egg...@gmail.com scribed:

>是否可以在不使用表单的情况下获取文件?
>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 just
save it to a variable. Similar to the post body of a form that has a
file input element in it.


我创建一个字符串,其中包含用
某些特殊字符分隔的经过验证的表单输入数据。与cookie值相同。您可以将它保存为日志条目,文件,长期cookie,无论您喜欢什么。


I create a string comprising the validated form input data separated with
some special character. Same as a cookie value is crafted. You can save it
as a log entry, a file, a long-term cookie, whatever your pleasure.


>最终我想做什么从客户端机器上获取一个文件(它们指定的文件)并使用标准的发布请求将其发送到服务器。
这与带有文件输入元素的表单帖子完全相同,但我不想使用表单,我想获取文件数据并先操作它然后将其发回。所以,问题是,如何在不使用表单的情况下从客户端获取文件?任何指针都会受到赞赏。
>Ultimately what I want to do is get a file off client machine (that
they 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 and
manipulate it first then post it back. So, the problem is, how can I
get the file from the client without using a form? Any pointers would
be appreciated.


在加载表单时,获取''encoded''值,将其拆分为特殊的
字符,以形成包含原始表单数据的数组,并使用
数组数据填写表格。
-
Ed Jay(删除''M''通过电子邮件回复)


On loading the form, fetch the ''encoded'' value, split it at the special
character to form an array comprising the original form data, and use the
array 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 File
input 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)


这篇关于使用表单发布从客户端获取文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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