上传图片时出现问题 [英] problem in uploading images

查看:107
本文介绍了上传图片时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想上传将保存在文件夹中的图像.该文件夹在我的网站文件夹内.例如: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'];


这篇关于上传图片时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆