Check if you're using enctype="multipart/form-data" on the form. More
info here:
http://us3.php.net/features.file-upload
Example:
<form enctype="multipart/form-data" action="post.php" method="POST">
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>
Glenn Coyle wrote:
Quote:
Hi
>
I am having trouble writing the file path of a image to the
database,also for some reason it is not uploading the images, anyone
have any ideas?
>
the code is below:
>
if($_POST[Submit] == 'Submit')
{
$target_path = "../reviewImages/";
$target_path = $target_path . basename(
$_FILES['uploadFile']['name']);
if(move_uploaded_file($_FILES['uploadFile']['tmp_name'],
$target_path)) {
echo "The file ". basename( $_FILES['uploadFile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try
again!";
}
echo $target_path;
>
$text = $_POST[text];
$press = $_POST[press];
$logo = "reviewImages/".basename( $_FILES['uploadFile']['name']);
echo $logo;
$title = $_POST[title];
$author = $_POST[author];
$date = $_POST['date'];
>
$sql = "INSERT into reviews (press, title, author, date, text,
imagePath) VALUES ('$press', '$title', '$author', '$date', '$text',
'$logo')";
mysql_query($sql) or die(mysql_error());
>
echo "Information added to the reviews table";
}
>
cheers
>
Glenn