上传图片时出现问题
问题描述:
我想上传将保存在文件夹中的图像.该文件夹在我的网站文件夹内.例如:mywebsite(网站文件夹). myimage(图像文件夹).
并且图像的路径应保存在mysql中.
我尝试了以下操作,但是它给出了错误找不到路径".这是我的路径:-C/wamp/www/mywebsite/myimage.
I want to upload images that will be saved in a folder. That folder is inside my website folder. eg: mywebsite(website folder). myimage(image folder).
And the path of image should be saved in mysql.
I tried the following but it is giving error "path not found." This is my path:- C/wamp/www/mywebsite/myimage.
$basePath = "myimage/";
$image = $_FILES['image'];
$storagePath = $basePath.$image['name'];
if (!is_dir($basepath)) {
echo "Base path '$basePath' does not exist";
}
else if (file_exists($storagePath)) {
echo "File '$storagePath' already exists";
}
else if (!move_uploaded_file($image['tmp_name'], $storagePath)) {
echo "Could not move file to '$storagePath'. Check read/write persmissions on the directory";
}
else {
$insertQuery = "INSERT INTO $tbl_name (myImage) VALUES ('".mysql_real_escape_string($image['name'])."')";
$execute=mysql_query($insertQuery);
答
basePath = " myimage/";
basePath = "myimage/";
图像 =
image =
_FILES [ ' 图片'];
_FILES['image'];