I want to upload user images from cli开发者_开发知识库ent machine to server in php. The name of the image should be predefined.
Can any one tell me the php code for this?
Will the example from the manual page for move_uploaded_file() do?
$uploads_dir = '/uploads';
foreach ($_FILES["pictures"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["pictures"]["tmp_name"][$key];
$name = $_FILES["pictures"]["name"][$key];
move_uploaded_file($tmp_name, "$uploads_dir/$name");
}
}
Also see the chapter on Handling File Uploads in the PHP Manual
精彩评论