开发者

PHP: Upload images from client machine to the server

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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜