在将文件上传到服务器时是否需要更改文件名?就像您在将文件存储到服务器之前生成新文件名一样。
答案 0 :(得分:0)
$temp = explode(".", $_FILES["file"]["name"]);
$newfilename = round(microtime(true)) . '.' . end($temp);
move_uploaded_file($_FILES["file"]["tmp_name"], "../img/imageDirectory/" . $newfilename);
答案 1 :(得分:0)
$image_name = addslashes($_FILES['file']['name']);
$temp = explode(".", $image_name);
$newfilename = round(microtime(true)) . '.' . end($temp);
$target = 'location/'.$newfilename;
move_uploaded_file($_FILES['file']['tmp_name'], $target);