I use file_put_contents to upload an image, but it can only be saved in the current directory. How can I move the image to the desired directory?

WBOY
Release: 2016-10-10 11:39:13
Original
1498 people have browsed it
<code>$id = $_POST['id'];
$name = $_POST['name'];
$address = $_POST['address'];
$phonenumber = $_POST['phonenumber'];
$image = $_POST['image'];//得到图片
$imageBase64 = base64_decode($image);

$host = $_SERVER['HTTP_HOST'];//获取主机IP
$post = $_SERVER['HTTP_PORT'];//获取主机端口


$imageName = $id.".png";//生成的图片名称和用户ID一样
$file_put = file_put_contents($imageName, $imageBase64);

</code>
Copy after login

I uploaded the image after converting it to Base64, but using the file_put_contents function can only be placed in the directory of the script. How can I move the uploaded image to the desired directory?

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template