Jump to content

haris244808

Members
  • Posts

    110
  • Joined

  • Last visited

    Never

Everything posted by haris244808

  1. Ok here i want to upload a picture in database: but it doesnt work where is the problem? here is my PHPcode: <?php $dbname="database_web"; $host="localhost"; $user=""; $pass=""; $link = mysql_connect($host, $user, $pass); mysql_select_db($dbname, $link); ?> <form method="post" enctype="multipart/form-data"> <table width="350" border="0" cellpadding="1" cellspacing="1" class="box"> <tr> <td width="246"> <input type="hidden" name="MAX_FILE_SIZE" value="2000000"> <input name="userfile" type="file" id="userfile"> </td> <td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td> </tr> </table> </form> <?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']; $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp); if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } $query = "INSERT INTO upload (name, size, type, content ) ". "VALUES ('$fileName', '$fileSize', '$fileType', '$content')"; mysql_query($query) or die('Error, query failed'); echo "<br>File $fileName uploaded<br>"; } ?> and here is my SQL code: CREATE TABLE upload ( id INT NOT NULL AUTO_INCREMENT, name VARCHAR(30) NOT NULL, type VARCHAR(30) NOT NULL, size INT NOT NULL, content MEDIUMBLOB NOT NULL, PRIMARY KEY(id) );
  2. i have tried so many codes and didn't achieve what i want because i that i posted maybe someone have a ready one and can send. however thank you for the reply. i placed this topic where u suggested
  3. Can you pls send me the SQL code, Php and html code because i also want to add this kind of forms to my site... THanks
  4. Here is a html form: i need help from someone to send me the database creation code and the php code needed to add this html form in DB... (ex: You put this html form in your website than Someone writes his name, surname chooses his city and uploads multiply pictures and they should be stored in DB) <body> <table border="0"> <form method ="post" action=""> <tr><td>Name</td><td><input type="text" name="name" size="40"></td></tr> <tr><td>Surname</td><td><input type="text" name="surname" size=40></td></tr> <tr><td>Email</td><td><input type="text" name="email" size="40"></td></tr> <tr><td>Tel. Nr</td><td><input type="text" name="number" size="40"></td></tr> <tr><td>Adress</td><td><input type="text" name="address" size="40"></td></tr> <tr><td>City</td><td><select name="city" size="1"> <option selected>A <option>B <option>C <option>D <option>E <option>F <option>G </select></td></tr> <tr><td>Info</td><td><textarea name="comment" rows =10 cols=40>write here...</textarea></td></tr> <tr><td>Upload </td> <td align="right"><input type="hidden" name="MAX_FILE_SIZE" value="500" > <input type="file" name="upload" size=30></td></tr> <tr><td></td><td align="right"> <br/><input type="submit" name="Dergo"> </form> </td></tr> </table> </body> Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.