PHP中同步上传的竞争条件
我的PHP请求处理程序如下所示:PHP中同步上传的竞争条件,php,file-io,upload,race-condition,Php,File Io,Upload,Race Condition,我的PHP请求处理程序如下所示: // it's one file only, always foreach($_FILES as $file){ // error checks, move etc. if(!move_uploaded_file ... // assemble if the number of files match the total number of parts $numFiles = count(glob("{$tempDir}/*", GLOB_N
// it's one file only, always
foreach($_FILES as $file){
// error checks, move etc.
if(!move_uploaded_file ...
// assemble if the number of files match the total number of parts
$numFiles = count(glob("{$tempDir}/*", GLOB_NOSORT));
if($numFiles === $totalChunks){ // <- problem
// assemble file
}
}
//始终只有一个文件
foreach($\u文件为$file){
//错误检查、移动等。
如果(!move_)上传了文件。。。
//如果文件数与零件总数匹配,则进行组装
$numFiles=count(glob(“{$tempDir}/*”,glob_NOSORT));
如果($numFiles===$totalChunks){//您是否尝试锁定()已组装的文件,以便即使条件中断,也没有两个脚本可以尝试在同一时间写入该文件。谢谢!使用lock_EX锁定它似乎可以完成此任务,尽管我现在遇到了一些用于执行某些文件处理的shell脚本的问题