I have a problem when I create a new directory with PHP when uploading a file.
The directory is created, but if another instance of the same script runs at the same time the directory exist check doesn't work correctly (gives PHP warning).
Someone told me it's a race condition but I still have this issue after adding some random sleep time.
usleep(mt_rand(1, 50));
if(!is_dir($dir)){
mkdir($dir);
}
usleep(mt_rand(1, 50));
can anyone help?
Does anybody know a safe way to upload a file in multiple parts, with 3-4 parts being uploaded at the same time? Currently I'm moving the uploaded parts in a temporary directory (is_dir fails on the temporary dir if more parts arrive at the same time), then when the number of files from that dir equal the number of parts the parts get combined. But it fails many times, sometimes is_dir gives warning, sometimes the parts get combined twice...