当前位置: 动力学知识库 > 问答 > 编程问答 >

Upload php script rename function

问题描述:

I have this PHP script and was wondering if somebody could help me with one question.

Lets say I upload a file named "me.jpg", What will the file be renamed to after it is uploaded?

 if($_FILES['q35']['tmp_name']){

$file_ext=eregi_replace("^(.*)\.(.*)$","\\2",$_FILES['q35']['name']);

$file_ext_35 = strtolower($file_ext);

if(in_array($file_ext, $whitelist)) {

move_uploaded_file($_FILES['q35']['tmp_name'], $url[server].'/images/'.$image_folder.'/selfie.'.$file_ext_35);

}

网友答案:

First you should replace eregi_replace by preg_replace. eregi_replace seems to deprecated. As for your question, let's assume your code would work, your picture's name would still be 'me.jpg'

分享给朋友:
您可能感兴趣的文章:
随机阅读: