Reply to Re: issues writing a image path to mysql database

Your name:

Reply:


Posted by petersprc on 10/04/06 02:28

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:
> 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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация