0

这是 php/ajax 上传脚本的一部分。有人知道如何上传到目录吗?

<?php

if(isset($_FILES["imageNameHere"]) && !empty($_FILES["imageNameHere"])) {
// Random name
$name= rand(10, 20).'.png';
// Move the file
//move_uploaded_file($_FILES["imageNameHere"]['tmp_name'], $name);//orginal

move_uploaded_file( $_FILES["imageNameHere"]["tmp_name"],$name, "uploads/" .  
$_FILES['imageNameHere']['tmp_name'][$name]); // My Try

// Return name
echo $name;
}
?>
4

1 回答 1

1

这应该有效,更改:

move_uploaded_file( $_FILES["imageNameHere"]["tmp_name"],$name, "uploads/" . $_FILES['imageNameHere']['tmp_name'][$name]); // My Try    

至:

move_uploaded_file( $_FILES["imageNameHere"]["tmp_name"], "uploads/" . $name); 

rand()但是,当两次生成相同的数字时,您会遇到问题。

于 2013-04-04T22:48:30.033 回答