[ Meklaud @ 04.03.2008. 23:18 ] @
Pozdrav svima, Nov sam u ovome, pa imam neki problem koji ocigledno ne vidim, pa moram da pitam. Hteo sam da ubacim sliku u bazu. Ali, ne da se slika, tj. ja je ne vidim u bazi sto znaci da kod ne radi. Evo i koda pa molim za pomoc. Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>File upload</title> </head> <body> <form action="" method="post" enctype="multipart/form-data" name="uploadImage" id="uploadImage"> <p> <label for="image">Upload image:</label> <input type="file" name="image" id="image" /> <input type="hidden" name="MAX_FILE_SIZE" value="96000"> </p> <p> <input type="submit" name="upload" id="upload" value="Upload" /> </p> </form> <?php // check if a file was submitted if(!isset($_FILES['image'])) { echo '<p>Please select a file</p>'; } else { try { upload(); // give praise and thanks to the php gods echo '<p>Thank you for submitting</p>'; } catch(Exception $e) { echo $e->getMessage(); echo 'Sorry, could not upload file'; } } function upload(){ if(is_uploaded_file($_FILES['image']['tmp_name'])) { // check the file is less than the maximum file size if($_FILES['image']['size'] < $maxsize) { // prepare the image for insertion $imgData =addslashes (file_get_contents($_FILES['image']['tmp_name'])); // $imgData = addslashes($_FILES['image']); // get the image info.. $size = getimagesize($_FILES['image']['tmp_name']); // put the image in the db... // database connection mysql_connect("localhost", "root", "boba") OR DIE (mysql_error()); // select the db mysql_select_db ("test") OR DIE ("Unable to select db".mysql_error()); // our sql query $sql = "INSERT INTO testblob ( image_id , image_type ,image, image_size, image_name) VALUES ('', '{$size['mime']}', '{$imgData}', '{$size[3]}', '{$_FILES['image']['name']}')"; // insert the image if(!mysql_query($sql)) { echo 'Unable to upload file'; } } } else { // if the file is not less than the maximum allowed, print an error echo '<div>File exceeds the Maximum File limit</div> <div>Maximum File limit is '.$maxsize.'</div> <div>File '.$_FILES['image']['name'].' is '.$_FILES['image']['size'].' bytes</div> <hr />'; } } ?> </body> </html> Kad ja ovo ucitam, otvori mi se forma i ja uradim upload slike od 19KB i on mi lepo kaze thank you for submitting. Naravno slike nema u bazi, tj. ja ne vidim tamo blob. Pomoc. Hvala [Ovu poruku je menjao Nemanja Avramović dana 05.03.2008. u 01:47 GMT+1] |