简体   繁体   English

验证PHP和Flash之间数据上传完整性的最佳方法

[英]Best way to verify data upload integrity between PHP and Flash

I have written an uploader for massive files (tens of gigs) in AIR, which sends small chunks of the file at a time (<1 meg) to the server (collected via PHP). 我已经在AIR中编写了一个用于上传大量文件(数十个演出)的上传程序,该文件一次将文件的小块(<1兆)发送到服务器(通过PHP收集)。

It works very nicely 99% of the time. 它在99%的时间内都能很好地工作。

However, there are rare instances where the collected file is corrupt. 但是,在极少数情况下,收集的文件已损坏。 I have no way to account for this, but my thought is that if I verify each slice as it goes up, this will fix the problem, so, the question is... what's the best way to verify? 我没有办法解决这个问题,但是我的想法是,如果我在每个切片上升时对其进行验证,这将解决问题,因此,问题是……验证的最佳方法是什么?

My impulse is to do an MD5, in PHP and send it back upon slice upload completion and then do an MD5 on the Flash side and compare. 我的冲动是在PHP中执行MD5,并在切片上传完成后将其发送回去,然后在Flash端进行MD5进行比较。

Performance isn't *too huge a concern, but if there's a more efficient (and equally simple) way to handle this, I'd rather do it that way. 性能并不是一个太大的问题,但是如果有一种更有效(同样简单)的方法来处理此问题,我宁愿那样做。 Ultimately I have no desire to reinvent the wheel. 最终,我不想重新发明轮子。

All suggestions welcome. 欢迎所有建议。

TIA TIA

I went with MD5. 我选择了MD5。 Seems to work brilliantly. 似乎工作出色。

The only thing I did differently than in my question was that I do the MD5 on the Flash side before I send it up and add that as a POST param. 我所做的唯一与问题不同的是,在将它发送并添加为POST参数之前,我先在Flash端执行了MD5。 Then, on the PHP side I can do a comparison as soon as the file arrives, and if they are not the same, I send back an error to the Flash. 然后,在PHP端,我可以在文件到达后立即进行比较,如果它们不相同,则将错误发送回Flash。 It may be a "6 of one 1/2 dozen of the other" difference, but it does appear more elegant to me (not sure why). 这可能是“一打一打的六分之六”的差异,但对我来说确实显得更优雅(不确定原因)。

Hope this helps someone. 希望这对某人有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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