首页  >  文章  >  后端开发  >  我用file_put_contents上传图片,但是只能保存在当前目录,怎么把该图片移动到想要的目录呢?

我用file_put_contents上传图片,但是只能保存在当前目录,怎么把该图片移动到想要的目录呢?

WBOY
WBOY原创
2016-10-10 11:39:131435浏览
<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>

我是把图片转换为Base64后上传的,但是用file_put_contents函数只能放在该脚本的目录,请问怎么把上传的图片移动到想要的目录下呢?

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn