I'm developing an Restful Services for Android application and i'm trying to upload image to localhost from application, but keep getting an error on finding the location where an image was stored.
I'm storing data in DB successfully, but not storing image in folder on localhost.
This is how i'm locating folder:
$path = "uploads/$id.png";
$actualpath = "http://localhost:8081/joke_bro/$path";
// creating new joke
$joke_id = $db->createJoke($user_id, $joke_text, $user_name, $actualpath, $image_name);
if ($joke_id != NULL) {
$response["error"] = false;
$response["message"] = "Joke created successfully";
file_put_contents($path, base64_decode($image));
echoResponse(201, $response);
} else {
$response["error"] = true;
$response["message"] = "Failed to create joke. Please try again";
echoResponse(200, $response);
}
actualpath is urlPathLink that i'm storing in DB, but i need now to store also image to that folder using function file_put_contents
. However i'm getting some error with path location of that folder.
Here is the error:
<strong>Message:</strong> file_put_contents(uploads/35.png): failed to open stream: No such file or directory
Here is the path from where i'm executing this code:
E:\xampp\htdocs\joke_bro\v1
And here i should store images:
E:\xampp\htdocs\joke_bro\uploads