| | |
Please I need help on image upload to mysql and display in browser
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2008
Posts: 9
Reputation:
Solved Threads: 0
Hi,
I am terribly stuck with this code. It is suposed to upload my images to the mysql database with the foreign key(property_id). At first it worked, then later started giving serious errors where the web page could not load. I am lost. Can any one help me, solve this...please
. Below is the code snippet. php Syntax (Toggle Plain Text)
<form method="post" enctype="multipart/form-data"> <table width="350" border="0" cellpadding="1" cellspacing="1" class="box"> <tr> <td class="formText">Property Description: <select name="userfile"> <?php do { ?> <option value="<?php echo $row_cust['property_id']?>"> <?php echo $row_cust['description']?> </option> <?php } while ($row_cust = mysql_fetch_assoc($cust)); $rows = mysql_num_rows($cust); if($rows > 0) { mysql_data_seek($cust, 0); $row_cust = mysql_fetch_assoc($cust); } ?> </select></td> <td width="125"> </td> </tr> <tr> <td> </td> <td></td> </tr> <tr> <td width="218"> <input type="hidden" name="MAX_FILE_SIZE" value="2000000"> <input name="userfile" type="file" id="userfile"> </td> <td width="125"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td> </tr> <tr> <td class="text" colspan="2"> <?php if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $pid = $_POST['userfile']['property_id']; $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp); if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } include 'library/config.php'; include 'library/opendb.php'; $query = "INSERT INTO upload (property_id, name, size, type, content ) ". "VALUES ('$pid', '$fileName', '$fileSize', '$fileType', '$content')"; mysql_query($query) or die('Error, query failed'); include 'library/closedb.php'; echo "<br>$fileName has been uploaded Successfully <br>"; } ?> </td> </tr> <tr> <td class="text" colspan="2"><a href="submit_thanks.php">Continue</a>, if done with image uploads.</td> </tr> <tr> <td colspan="2"> </td> </tr> </table> </form>
read this article easy and full of code (one secret thing is that i make my first image upload module from the same code)
url is
http://www.wellho.net/solutions/php-...-retreive.html
url is
http://www.wellho.net/solutions/php-...-retreive.html
Help as an alias
I think programming is great................
Tour Travel weblink by me and about Tour ,
Go To My Home Page and I m in Webdevelopment.
I think programming is great................
Tour Travel weblink by me and about Tour ,
Go To My Home Page and I m in Webdevelopment.
![]() |
Other Threads in the PHP Forum
- Previous Thread: Newbie email error
- Next Thread: Socket programming
| Thread Tools | Search this Thread |
5.2.10 action address ajax apache api array auto autoincrement beginner binary broken cakephp checkbox class classes cms code cron curl database date dehasher destroy display domain dynamic echo email error errorlog fatalerror file files folder form forms function functions google href htaccess html if-else image include insert integration ip java javascript joomla limit link load login mail masterthesis menu mlm multiple mysql mysqlquery oop paypal pdf php popup problem query radio random record recursion regex remote script search security server sessions sms soap sockets source space sql syntax system table tutorial update upload url validator variable video web xml youtube





