IamMe. IamMe. - 5 months ago 18x
PHP Question

How to upload images to a domain at webhost using php?

What should I do if I want to upload an image to a file system such as a folder in my domain? The thing is, I've tried uploading image on a localhost and it works fine but when i did it in my domain it doesn't work anymore. Don't really know what's the problem here. any help will do! Thanks anyway.

<form action="adminUploadTry.php" method="post" enctype="multipart/form-data">
<input type="file" name="image" >
<input type="submit" name="submit" value="Upload" >

$image_name = $_FILES['image']['name'];
$image_type = $_FILES['image']['type'];
$image_size = $_FILES['image']['size'];
$image_tmp_name = $_FILES['image']['tmp_name'];

echo "You forgot to select an image. Please choose one!";

move_uploaded_file(image_tmp_name, "/home/stagcon2/public_html/StagConnect/admin/pictures/$image_name");

echo "Image Succesfully Uploaded!";
echo "<img src='/home/stagcon2/public_html/StagConnect/admin/pictures/$image_name'>";

by the way, the problem here is that after i uploaded an image it will say "successfully uploaded" but when I check my folder the image was not saved.


May be you forget $ sign in image_tmp_name at

move_uploaded_file($image_tmp_name, "/home/stagcon2/public_html/StagConnect/admin/pictures/$image_name");