node js POST请求multipart / form-data,如何更改name属性

时间:2015-12-22 09:14:21

标签: javascript post request multipartform-data

我正在尝试通过POST请求上传照片并附上请求(https://github.com/request/request)或 restler(https://github.com/danwrong/restler

如果我想像这样将表格上传到upload.php,如何设置输入名称属性(值)(name =" file")?

<form  action="upload.php" method="POST" enctype="multipart/form-data">
      <input type="file" name="file" >  <!-- <<<this   -->
      <input id="submit" name="submit" type="submit" value="upfile">
</form> 

2 个答案:

答案 0 :(得分:0)

the documentation链接到:

my_file: fs.createReadStream(__dirname + '/unicycle.jpg'),

my_file是字段名称。

答案 1 :(得分:0)

这可以帮助您

    <form action="upload.php" method="post" enctype="multipart/form-data">
    Select image to upload:
    <input type="file" name="fileToUpload" id="fileToUpload">
    <input type="submit" value="Upload Image" name="submit">
</form>

您还可以看到此链接....

[http://www.w3schools.com/php/php_file_upload.asp][1]