上传图片时出现问题(problem in uploading images)
IT问题网 2021-02-22 00:00:00
问 题
我想上传将保存在文件夹中的图片。该文件夹位于我的网站文件夹中。例如:mywebsite(网站文件夹)。 myimage(图片文件夹)。
图像的路径应该保存在mysql中。
我尝试了以下但是它给出错误"找不到路径"。这是我的路径: -c / wamp / www / mywebsite / myimage。
$ basepath = " myimage /";
$ image = $ _files [' 图像'跨度>];
$ storagepath = $ basepath。$ image [' 名称跨度>];
if (!is_dir($ basepath)){
echo " 基本路径'$ basepath'不存在";
}
else if (file_exists($ storagepath)){
echo " 文件'$ storagepath'已存在"跨度>;
}
else if (!move_uploaded_file($ image [" tmp_name'],$ storagepath)){
echo " 无法将文件移动到"$ storagepath"。检查目录"/ / span"上的读/写持久性>;
}
else {
$ insertquery = " insert into $ tbl_name(myimage)values('" .mysql_real_escape_string($ image [' name'])。" ')"跨度>;
$ execute = mysql_query($ insertquery);
解决方案
basepath = " myimage /";
image =
_files [' image'];
分享:
热门推荐