Categories:
.NET (357)
C (330)
C++ (184)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (2)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How To Uploaded Files to a Table
How To Uploaded Files to a Table? - PHP Script Tips - Uploading Files to Web Servers
✍: FYIcenter.com
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.
2007-04-19, 5319👍, 0💬
Popular Posts:
How To View All Columns in an Existing Table? - Oracle DBA FAQ - Managing Oracle Database Tables If ...
I have 5 questions please give me the answer ,explanation,suggestions if any?? what is PMP(project m...
Are risk constant through out the project ? * Never say that risk is high through out the project. R...
Enable ASP.NET polling using “web.config” file Now that all our database side is configured in order...
What is a measure in OLAP ? Measures are the key performance indicator that you want to evaluate. To...