Media Informasi

Media Informasi harian terkini

  • Home
Home » PHP , Trik » Upload Files into Database

Upload Files into Database

  aditya    

How To Upload Files into Database?
To store uploaded files to MySQL database, you can use the normal SELECT statement as shown in the modified processing_uploaded_files.php listed below:
<?php
$con = mysql_connect("localhost", "", "");
mysql_select_db("fyi");
$error = $_FILES['fyicenter_logo']['error'];
$tmp_name = $_FILES['fyicenter_logo']['tmp_name'];
$size = $_FILES['fyicenter_logo']['size'];
$name = $_FILES['fyicenter_logo']['name'];
$type = $_FILES['fyicenter_logo']['type'];
print("
\n");
if ($error == UPLOAD_ERR_OK && $size > 0) {
$fp = fopen($tmp_name, 'r');
$content = fread($fp, $size);
fclose($fp);
$content = addslashes($content);
$sql = "INSERT INTO fyi_files (name, type, size, content)"
. " VALUES ('$name', '$type', $size, '$content')";
mysql_query($sql, $con);
print("File stored.\n");
} else {
print("Upload faield.\n");
}
print("
\n");
mysql_close($con);
?>
Note that addslashes() is used to add backslashes to special characters that need to be protected in SQL statements.
Label: PHP, Trik

Arsip Blog

Popular Posts

  • Contoh soal dan pembahasan Kalkulus 1 Integral
  • Membuat Login Form dengan PHP [Level Multi User]
  • Vocaloid 2 Hatsune Miku Full [Free Download]
  • Cara Import Database Ke Phpmyadmin yang File Nya *.opt *.frm *.MYD *.MYI
  • Cara Membuat Program Olah Data Sederhana menggunakan Netbean
  • Cara Menggunakan SSH di Android
  • Tutorial Mencari BUGS Host , Website , Server
  • Resident Evil 6 (2013) Full Version Pc Game Download Full Crack Patch iso
  • After "Submit", redirect back to previous page php
  • Buat text bergerak segala arah

Label

  • Trik (49)
  • software (49)
  • Info (47)
  • PHP (47)
  • tutorial (27)
  • Website (24)
  • Belajar (23)
  • Java (12)
  • Algoritma (11)
  • games (11)
  • Teknologi (9)
  • SEO (8)
  • berita (8)
  • film (8)
  • Design (6)
  • database (5)
  • promo (2)

Pengunjung

About

SEO Starter is SEO and Mobile Friendy Blogger Template. Responsive Sesuai dengan Rekomendasi Google

Web Links

  • Blogger Platform
  • CMS WordPress
  • Facebook
  • Microblogging
  • Manchester United

Follow by Email

Subsribe to get post update from this blog in your email inbox.

Copyright © Media Informasi. All rights reserved. Template by Romeltea Media