0

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);															   					 }
4
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by pinkygirl
0

Where is your input coming from?
Is the name of the file upload form image?

Edited by dmservers: n/a

0

Try with $_SERVER. Example below.

$basePath = $_SERVER['DOCUMENT_ROOT'] . "/mywebsite/myimage/";
0

i tried

$basePath = $_SERVER['DOCUMENT_ROOT'] . "/mywebsite/myimage/";

, it's saying the path does not exists.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.