How to upload an image on the internet? right now the script below works on local host but i have issues when its hosted. any one have any ideas?
<?php
// form in which we can upload the image
session_start();
include("connect.php");
// session as on website.
$jobseekerid = $_SESSION['jobseekerid'];
if($_POST['submit'])
{
//get file attributes
$name = $_FILES['myfile']['name'];
$tmp_name = $_FILES['myfile']['tmp_name'];
if ($name)
{
// start upload process
$location ="pictures/$name";
move_uploaded_file($tmp_name,$location);
// updating table users (setting image locaion
$query = mysql_query("UPDATE jobseekers SET imagelocation='$location' WHERE jobseekerid='$jobseekerid'");
die("Your avatar has been uploaded! <a href='profile.php'>Go back to view</a>");
}
else
die("Please Select a file!");
}
echo "Welcome, ".$_SESSION['username']."!<br><a href='logout.php'>Logout</a>";
echo "Upload Your image:
<form action='upload.php' method='POST' enctype='multipart/form-data'>
File: <input type='file' name='myfile'> <input type='submit' name='submit' value='upload!'
>
</form>
";
?>
A possible problem is that you don't have permissions to write into the target directory!!
Please check if you are able to with your provider. You may have to set FTP permissions 777 to upload directory or to choose a different upload path that is given by your ISP.
At least that is the most typical issue.
And please, next time format your questions better.