开发者

Does PHP's $_FILES re-use filenames on the server?

I'm building the image uploading component for a social networking site. I am uploading multiple files using imgfile[] as the <input>'s name and this part is working fine.

$upload_form.= "<ul class='imgfile_ul' id='$imgfile_ul_id' style='padding:0px'>";
$upload_form.=      "<li class='' id='$imgfile_li_id' style='border:0px'><label class='msgs_in_black'>Filename:</label><input type='file' name='imgfile[]' class='imgfile_cls' id='$imgfile_id'/></li>";
$upload_form.= "</ul>";

My question is about what happens when I display the uploaded files.

for(开发者_如何学C$i=0;$i<$files_cnt;$i++){
        $temp_name = $_FILES['imgfile']['tmp_name'][$i];
        $file_name = $_FILES['imgfile']['name'][$i];

If two users upload files at the exact same time from two different places, is there a chance it will use the same filename and I'll receive the other user's files instead of the correct one?


PHP creates a unique temporary file for every uploaded file - the odds that two different uploadds would receive the same randomly generated name are essentially non-existent.


the $_FILES variable is local to the currently executing script (started by the http post request), so it's not possible a user will get another users uploaded files

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜