โหนด js POST ร้องขอ multipart/form-data วิธีเปลี่ยนชื่อแอตทริบิวต์

ฉันกำลังพยายามอัปโหลดรูปภาพผ่านคำขอ POST ด้วยคำขอ (https://github.com/request/request) หรือ restler(https://github.com/danwrong/restler)

ถ้าฉันต้องการทำเหมือนแบบฟอร์มนี้เพื่ออัปโหลดรูปภาพไปยัง upload.php จะตั้งค่าแอตทริบิวต์ชื่ออินพุต (ค่า) (ชื่อ = "ไฟล์") ได้อย่างไร?

<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> 

person Finn    schedule 22.12.2015    source แหล่งที่มา


คำตอบ (2)


จากเอกสารที่คุณเชื่อมโยงกับ:

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

my_file คือชื่อฟิลด์

person Quentin    schedule 22.12.2015
comment
my_file เป็นแอตทริบิวต์ของชื่อใช่ไหม ถ้า ‹input type=file name=file › , ชุดคือ my_file: 'file' ? - person Finn; 22.12.2015
comment
ไม่ หากชื่อฟิลด์เป็น file คุณจะต้องพูดว่า file: fs.createReadStream(__dirname + '/unicycle.jpg'), - person Quentin; 22.12.2015

สิ่งนี้อาจช่วยคุณได้

    <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]

person S.Rusdana    schedule 22.12.2015