0

I have been struggling with this for some time and cant find any solutions that work for me The max image size is 1MB.

Below is my existing SQL statement:

$sql = "INSERT INTO bird(Name,UserID,TypeID,Picture) VALUES ('$_POST[Name]','$row[UserID]','$_POST[Type]','$_POST[Picture]')";

Also my html:

<form method="post" action='submit.php' enctype='multipart/form-data'>
    Picture<br>
    <input type="file" name="Picture" class="field"/>
    <span class="error"><?php echo $PictureErr?></span><p>
    <input type="submit" name="Submit" value="Submit" class="button"/><p>
</form>

Have no idea where to even start with the php validation as Imassuming theyll be needed

Note:Before anyone asks, yes it is a requirement

ababusa
  • 240
  • 2
  • 10
  • 1
    You need to access the uploaded image (file) with `$_FILES` and not `$_POST`. What type is the `Picture` row in your database? – Drown Dec 10 '14 at 13:30
  • Have a look at http://stackoverflow.com/questions/450876/upload-image-to-server-using-php-store-file-name-in-a-mysql-database-with-othe similar to your ones – M Khalid Junaid Dec 10 '14 at 13:30
  • Its a 'blob' file Drown – ababusa Dec 10 '14 at 13:33
  • That link did help to an extent Khalid, its gone into Db as a binary file, that sounds right to you? – ababusa Dec 10 '14 at 13:42
  • I advice you to not saving images in the database. Bigger database size with no any obligate need is a nightmare in backup or migration. – SaidbakR Dec 10 '14 at 13:46
  • This is not going live, dont worry, its actually part of my assignment scenario so it kinda is needed bud – ababusa Dec 10 '14 at 13:58
  • @adabusa Fair enough, but as a future reference it makes more sense to store the image names and perhaps the folder structure but that's about it. Although some companies want to save everything as a blob but in those cases they have access to very large data storage so it's somewhat justifiable. – Jonast92 Dec 10 '14 at 14:11

0 Answers0