我要上传的图像将被保存在一个文件夹。该文件夹是我的网站文件夹内。例如:mywebsite网页(文件夹)。 myimage(图像文件夹中)。
和图像的路径应保存在MySQL
我尝试了以下,但它给错误"路径未找到。"这是我的路径: - / 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);