I'm making a simple PHP application which can upload an image to server.
I did it in my localhost, everything works well, but when I did it in real server. I mean web.com, it didn't work.
Here is my PHP script :
<?php
require "init.php";
$encoded_string=$_POST["encoded_string"];
$userfname=$_POST["userNameOf"];
$decoded_string=base64_decode($encoded_string);
$string= str_replace(' ','', $userfname);
$path="http://mybookshare.com/photos/" .$string. ".jpg";
file_put_contents($path,$decoded_string);
$query = "UPDATE user SET ProfPicture='$encoded_string' WHERE UserFN='$userfname' AND ProfPicture IS NULL";
$result = mysqli_query($conn, $query);
if($result) {
echo "success";
} else {
echo "failed";
}
mysqli_close($conn);
?>
The script is located in htdocs/app
, and the upload file destination of the picture is at htdocs/photos
Any help please?
Problem : You don't have photos
directory as in your script directory.
Solution : Try to move your photos
directory from your sub directory to your script main directory where your PHP file is present and then you will have no errors.As you can see that the script says that your directory is not present so that's why it's failing to do the rest of process.
Heads Up : I already said the same thing in my first comment but seems like you didn't give much attention to it.as you were mentioning the photos directory as to be present in your php script directory for your php to work it out with that and then you were not having the photos directory there so that's what was causing the error.!