Tag Archives: upload

Node Error: Error: Multipart: Boundary not found [How to Solve]

The front end uses httpclient in the angular library to upload files and set

headers: { ‘Content-Type’: ‘multipart/form-data’ }

When the backend uses featurejs to receive, an error is reported

error: multipart: boundary not found
error reason: multipart does not find the boundary

The uploaded file is a form in multipart/form data format of post request

content-type: multipart/form-data is not followed by the boundary

To sum up, the request header was set many times, overwriting the original form enctype = “multipart/form data”

Conclusion: it is not necessary to set content type: Music/form data repeatedly, otherwise the original may be overwritten and unexpected errors may be caused.


Correct way to get headers:

When uploading formdata type data, you do not need to manually set content typebrowser performance:

it’s done!

Using common file upload to upload files in SSH project

Today, the project used to upload. What I store in my database is the URL of the file, so I have to do some processing in the background. I have written several times before uploading, and I feel that the amount of code is too large. Today, I searched the Internet, and it will be much easier to upload with common file upload. After groping for an afternoon, I finally got it done. The background code is as follows

//The uploaded file
private File upload;
//file name and type
private String uploadContentType;
private String uploadFileName;
/*This is the variable to be written in the action, you must write it, otherwise it will be very troublesome, Struts2 will automatically assign the file to be uploaded, the file name, type, etc.*/

/// The following is the processing method
public String uploadStaffImage() throws Exception{
	//Take the file name and path, rename the file name with uuid to prevent Chinese mess
	String fileName = UUID.randomUUID().toString();
        //intercept file type
        String fileType = this.uploadFileName.substring(this.uploadFileName.lastIndexOf("."), this.uploadFileName.length());
        //New file name
        String file = fileName + fileType;
        // My directory is under "StaffImg" folder
        String path = request.getSession().getServletContext().getRealPath("/StaffImg");
	InputStream is = new FileInputStream(getUpload());  
        //Create an output stream to generate a new file  
        OutputStream os = new FileOutputStream(path + "//" + file);  
        //write disk 
        IOUtils.copy(is, os);
        os.flush();  
        IOUtils.closeQuietly(is);
        IOUtils.closeQuietly(os);
        //Update the URL in the database
        String imgURL = "StaffImg/"+file;
        this.staffFileUpLoadService.updataStaffImgURL(this.staffId, imgURL);
	return SUCCESS;
}

A total of 13 lines of code, compared to the previous written to be a lot more concise, method use is relatively simple.

This method can only upload a single file. If you upload in batches, the idea is the same, and you should add a loop in the outer layer
instead

TFTP: server says: file not found solution

Under Linux, regardless of which super-Server, inetd, or xinetd is used, the TFTP service is disabled by default, so modify the file to open the service.
According to the installation method of (1), the file /etc/xinetd.d/ TFTP can be modified. It is mainly to set the root directory of the TFTP server and start the service. The modified file is as follows:
service tftp
{socket_type = dgram
Protocol = udp
Wait = yes
User = root
Server =/usr/sbin/in TFTPD
Server_args = -s/home/LQM/tftpboot – c
Disable = no
Per_source = 11
The CPS = 100 2
Flags = IPv4
}
Server_args = -s < server_args= -s < path> -c, where < path> Change to the root directory of your TFTP-server. The parameter -s specifies chroot and -c specifies that files can be created.
3. Create TFTP root directory and start TFTP-Server.
#mkdir /home/lqm/tftpboot
# chmod o + w/home/LQM/tftpboot
#service xinetd restart
Stop xinetd: [sure]
start xinetd: [sure]
At this point, TFTP-Server is started. You can log in to test the following commands:
# TFTP & lt; your-ip-address>
tftp> get < download file>
tftp> put < upload file>
tftp> q
#

installation process problems and causes
phenomenon 1:
tftp> Log
Transfer timed out.
reason:
TFTPD service doesn’t start
Phenomenon.
tftp> put test2
Error code 0: Permission denied

run the command, check the system log
# tail /var/log/messages
found the following text:
Mar 24 19:05:26 localhost set: SELinux is preventing /usr/sbin/in. TFTPD (tftpd_t) \”write\” to tftpboot (tftpdir_t). For complete SELinux messages.run sealert-l 40a5a6bf-8ded-4bfa-ab6e-fa669a25fc6c
know this is caused by SELinux, in FC3 and FC versions after FC3 SELinux is turned on by default, now close it, modify the file /etc/sysconfig/ SELinux, set which
SELINUX=disabled
Then restart the computer
Or execute the system-config-SecurityLevel command to open the Security-Level Configuration dialog box and change “forced” to “allowed” in the SELinux (S) option.
Phenomenon 3:
tftp> Log
Error code 1: File not found
reason:
specified File does not exist; Or the -c option is not specified in the TFTPD boot parameter, allowing the file to be uploaded
Phenomenon 4:
tftp> Get test.log
Error code 2: Only absolute filenames allowed
reason:
server_args set in /etc/xinetd.d/ tftpd-hpa
cat /etc/defaul/tftpd-hpa
#Defaults for tftpd-hpa
#Defaults for tftpd-hpa
RUN_DAEMON=\”no\”
OPTIONS=\”-s /home/tftpd-c-p-u 077-u To set TFTPD \”
, simply change server_args = to your server folder

IIS 7.5, ASP.NET MVC. HTTP error 500 (internal server error), but debugging does not enter the background, the browser only reports 500 errors

Bugs, such as:
IIS 7.5, ASP.NET MVC. HTTP Error 500 (Internal Server Error) uploadify uploads images, the browser only reported 500 errors, the progress bar does not move, but debugging does not enter the background
After several days of searching, I could not debug the source of the error. I also wondered whether the maximum byte limit of the upload was limited. However, I finally found the prompt of foreign gods under Google and determined that it was this error.
http://stackoverflow.com/questions/17188930/iis-7-5-asp-net-mvc-http-error-500-internal-server-error-an-unexpected-cond
Solutions:
& lt; The httpRuntime requestValidationMode = “2.0” maxRequestLength = “100000”/& gt; The configuration file adds a maximum byte limit