Wayniac Posted December 31, 2009 Share Posted December 31, 2009 Greetings everyone, The issue I am having is uploading the image to my database. The config file that is being included is correct and the text uploads perfectly fine when I hit submit. But along with the text, when I hit submit, the image is suppose to upload as well. Unfortunately that is not the case, I check the database field (imgdata) that the image should be stored in and it reads no data, so no image uploaded. There is no image size restriction added yet so that can't be the case. Any suggestions? Here is the code below, thank you very much! <?php //error_reporting(0); include("config.php"); // Connect to database if ($_REQUEST[completed] == 1) { $newname = uniqid("whc").".jpg"; move_uploaded_file($_FILES['imagefile']['tmp_name'], "../upload/$newname"); } if(isset($_POST['submit'])) { $newname = mysql_real_escape_string($_POST['imgdata']); $title = mysql_real_escape_string($_POST['title']); $age = mysql_real_escape_string($_POST['age']); $testimonial = mysql_real_escape_string($_POST['testimonial']); if(!$title){ echo "Error: Entry title is a required field."; exit(); } $result = mysql_query("INSERT INTO album (imgdata, title, dtime, age, testimonial) VALUES ('$newname','$title',NOW(),'$age','$testimonial')",$connect); echo "<b>Entry UPDATED Successfully!<br>You'll be redirected to View Album page after<br>(4) Seconds"; echo "<meta http-equiv=Refresh content=4;url=index.php>"; } else { ?> </span></h3> <h3><span class="TextoBase"><font color=red> <?= $errmsg ?> </font></span></h3> <table border="0"> <tr> <td colspan="4"><form action="<?php $_SERVER['PHP_SELF'] ?>" method="post" enctype="multipart/form-data" name="" id="form"> <table width="200" border="0" class="TextoBaseTitulo"> <tr> <td> Please choose an image to upload:</td> </tr> <tr> <td><input name="imagefile" type="file" size="28"></td> </tr> <tr> <td>Title: <input type="hidden" name="MAX_FILE_SIZE" value="15000000"> <input type="hidden" name="completed" value="1"></td> </tr> <tr class="TextoBase"> <td><input name="title" size="40" maxlength="255"></td> </tr> <tr> <td>Age (Years):</td> </tr> <tr class="TextoBase"> <td><input name="age" type="text" value="" size="40"></td> </tr> <tr> <td>Testimonial:</td> </tr> <tr class="TextoBase"> <td><textarea name="testimonial" rows="7" cols="31"></textarea></td> </tr> <tr> <td><input type="submit" name="submit" value="Add Entry"></td> </tr> </table> </form></td> <td width="120"> </td> <td width="233"><img src=?gim=1 alt="" width=250></td> </tr> </table> <?php }//end of else ?> <span class="TextoBase"> </span></td> <td width="137" height="394" class="img_right_panel"> </td> </tr> <tr> <td height="143" colspan="4" align="center" class="img_footer"><p><br> <br> <a href="http://www.example.com/">Home</a> | <a href="index.php">View Album</a> | <a href="add_entry.php">Add Entry</a> </p></td> </tr> <tr> <td><img src="images/spacer.gif" width="142" height="1" alt=""></td> <td><img src="images/spacer.gif" width="670" height="1" alt=""></td> <td><img src="images/spacer.gif" width="1" height="1" alt=""></td> <td><img src="images/spacer.gif" width="137" height="1" alt=""></td> </tr> </table> </center> </body> </html> Quote Link to comment Share on other sites More sharing options...
anthylon Posted December 31, 2009 Share Posted December 31, 2009 Are you sure that you want to upload image in your database? Having images in database will slow down your application completely :'(. I wouldn't do that but it depends off your application requirements. Anyway, my advice: do not do that! Don't save image in database instead of storing image path only. Quote Link to comment Share on other sites More sharing options...
Wayniac Posted December 31, 2009 Author Share Posted December 31, 2009 I'm all ears, any suggestions on how I might go about doing that? Quote Link to comment Share on other sites More sharing options...
anthylon Posted December 31, 2009 Share Posted December 31, 2009 Here you go Mr. Ear - just kidding - check the following topic http://www.phpfreaks.com/forums/index.php/topic,281071.msg1331956.html Good luck! Quote Link to comment Share on other sites More sharing options...
Wayniac Posted December 31, 2009 Author Share Posted December 31, 2009 Thanks for the tip, I will look into setting this up via URL. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.