开发者

PHP: Upload images from client machine to the server

开发者 https://www.devze.com 2022-12-15 14:36 出处:网络
I want to upload user images from cli开发者_开发知识库ent machine to server in php. The name of the image should be predefined.

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

精彩评论

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

关注公众号