Nit Nit - 1 month ago 6
MySQL Question

Images are not uploading to the specific folder when I switch to localhost to server

I uploaded my php website to a server and updated the username, password, db_name but not the server. After submitting the form data saved in DB but images not uploading into the folders. Should I have to change the path of uploading folder or the hosting server?

$upload="uploads/.$filename"; I used when i was in localhost, and now the I uploaded this form in servername/db/index.php

This is the current code when submitting a new image.


if(isset($_POST['submit'])) {
$filename=$_FILES['image']['name'];
$temp_name=$_FILES['image']['tmp_name'];
$upload="uploads/.$filename";
$move=move_uploaded_file($temp_name,$upload);

$sql = mysqli_query($connection,"INSERT INTO member(member_image,id_img) VALUES '$filename','$filename1')"); }
?>

Answer

Please look at your file manager and check for things like your server username, public domain and reference your location where you want to upload your files as per your server for instance something like

$targer_dir = "/home/server_username/publi_html/myuploads/";

e.g $target_dir = "/home/jacksiroc/public_html/mymedia/images/

then ensure that you have the right permission to allow you to upload the files there.