简体   繁体   中英

file upload integrity check

I have file uploads in a form like photo or some other documents. Sometimes the file get uploaded ie,the file path will be there but the size will be 0 bytes or a part file. Please suggest me a solution to check the complete integrity check for such uploads. I have one solution to find the file size and check it after upload complete, is this a reliable solution?, any other good methods?

Finding the size is not a completely reliable solution. I would recommend you to use checksum for checking the integrity of file transferred. Client should calculate the checksum of file it is sending, send the checksum value with the request as a param. On the server side, again checksum should be calculated and compared against the checksum sent by the client. If two matches, file is good!

Here is a sample to generate checksum in java:

http://www.mkyong.com/java/how-to-generate-a-file-checksum-value-in-java/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM