我想将文件上传到服务器。 (node.js,文件上传)

时间:2018-01-18 16:30:57

标签: node.js file-upload

我想将文件上传到本地运行的服务器。

html表单来源

<form method="post" action="/plate/add-usb" class="edit-page" enctype="multipart/form-data">
		<div class="row">
			
			<div class="col-md-6">
				<label for="file" translate>File From USB</label>
				<select name="USBFile" id="file" class="form-control">
				
					<option value="/media/usb0/8.zip">/media/usb0/8.zip</option>
				
					<option value="/media/usb0/test123.stl">/media/usb0/test123.stl</option>
				
					<option value="/media/usb0/untitled.stl">/media/usb0/untitled.stl</option>
				
				</select>
			</div>
			
			<div class="col-md-6">
				<label for="Path" translate>Plate Name</label>
				<input value="" name="Path" id="Path" class="form-control" required>
				<br>
			</div>
		</div>
		<br>
		<button type="submit" class="btn btn-success" translate>Submit</button>
	</form>

<form method="post" action="/plate/add-usb" class="edit-page" enctype="multipart/form-data">
		<div class="row">
			
			<div class="col-md-6">
				<label for="file" translate>File From USB</label>
				<select name="USBFile" id="file" class="form-control">
				
					<option value="/media/usb0/8.zip">/media/usb0/8.zip</option>
				
					<option value="/media/usb0/test123.stl">/media/usb0/test123.stl</option>
				
					<option value="/media/usb0/untitled.stl">/media/usb0/untitled.stl</option>
				
				</select>
			</div>
			
			<div class="col-md-6">
				<label for="Path" translate>Plate Name</label>
				<input value="" name="Path" id="Path" class="form-control" required>
				<br>
			</div>
		</div>
		<br>
		<button type="submit" class="btn btn-success" translate>Submit</button>
	</form>

curl命令在命令linux

中有效

curl'http://172.30.1.5/plate/add-usb'-H'内容类型:multipart / form-data; boundary = ---- WebKitFormBoundaryEKR2KQHVlfoRK7rq' - data-binary $'------ WebKitFormBoundaryEKR2KQHVlfoRK7rq \ r \ nConContent-Disposition:form-data; name =“USBFile”\ r \ n \ r \ n / media / usb0 / a8.zip \ r \ n ------ WebKitFormBoundaryEKR2KQHVlfoRK7rq \ r \ nConContent-Disposition:form-data; name =“Path”\ r \ n \ r \ n \ na8 \ r \ n ------ WebKitFormBoundaryEKR2KQHVlfoRK7rq \ r \ nConContent-Disposition:form-data;名称= “简档为” \ r \ n \ r \ N3 \ r \ n ------ WebKitFormBoundaryEKR2KQHVlfoRK7rq \ r \ N'

我不知道如何输入代码。 请编写node.js代码。

0 个答案:

没有答案