eyehawk78 Posted April 11, 2006 Share Posted April 11, 2006 I am trying to use a html upload field to allow users to submit images to me that will be placed in my sql data base. i have sorted out the vaildation and submits the name and size to the database, but i need help with actually submitting the image to the database as a BLOBso the code i have is:<HTML><HEAD><?php$error = "";$valid=0;$filename = $HTTP_POST_FILES['file']['name'];$filesize = $HTTP_POST_FILES['file']['size'];$filetype = $HTTP_POST_FILES['file']['type'];$filetempname = $HTTP_POST_FILES['file']['tmp_name'];if(!$filename == ""){if($filetype == "image/gif"){$error = "successful";$valid++;}else if($filetype == "image/x-png"){$error = "successful";$valid++;}else if($filetype == "image/pjpeg"){$error = "successful";$valid++;}else if($filetype == "image/bmp"){$error = "successful";$valid++;}else {$error = "Incorrect file type, please upload image files of type .gif .bmp .png or .jpeg";$valid=0;}$maxsize=65536;$minsize=1024;if($error == "successful"){if($filesize <= $minsize){$error = "The file is too small, when this logo is placed onto shirt it will be disorted";$valid=0;}else if($filesize > $maxsize){$error = "The file is too large";$valid=0;}else {$error = "The file was successfully uploaded";$valid++;}}if($valid==2){$dbUser="blahblah";$dbHost="blahblah";$dbName="blahblah";$dbPass="blahblah";$dbc=mysql_connect($dbHost,$dbUser,$dbPass);$selected=mysql_select_db($dbName,$dbc);$query1="INSERT INTO upload VALUES('', '$filename', '$filetype', '$filesize', [!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]'this is were the blob field is in my database[!--colorc--][/span][!--/colorc--]')";if(mysql_query($query1)){$error == "Your file was successfully submitted";}else {$error == "Your file could not be submitted";}$valid=0;}$filename = "";$filesize = "";$filetype = "";$filetempname = "";}?></HEAD><BODY><form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data"><font face="Verdana" color="#000000" font size="2" >Choose a file to upload:<br></font><input type="file" name="file"><input type="submit" name="submit" value="Submit"><br><br><font face="Verdana" color="#000000" font size="2" ><?php print("$error</br>"); ?></font></form></BODY></HTML>could any one help me please? Quote Link to comment Share on other sites More sharing options...
shocker-z Posted April 12, 2006 Share Posted April 12, 2006 Sorry i'm unable to post the answer as it wont update the post! very weird! heres a link to what the correct code should be :)[a href=\"http://pctechsupport.sytes.net/blobdatabase.phps\" target=\"_blank\"]http://pctechsupport.sytes.net/blobdatabase.phps[/a]Ther's your answer Quote Link to comment Share on other sites More sharing options...
eyehawk78 Posted April 19, 2006 Author Share Posted April 19, 2006 Hi sorry to bother you again but i ran your code and i recieved to warnings.Warning: fread(): supplied argument is not a valid stream resource in C:\unzipped\CPT 06\uploadpage.php on line 14Warning: fclose(): supplied argument is not a valid stream resource in C:\unzipped\CPT 06\uploadpage.php on line 16what do these warnings mean?The blob size is still 0 bytes in my database. 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.