\r\n <\/td>\r\n | <\/td>\r\n | <\/td>\r\n <\/tr>\r\n<\/table>\r\n<\/body>\r\n<\/html><\/pre> \r\n\tindex_ok.php:<\/p> \r\n\"; \r\n\t}else{echo \"文件上傳失敗!!\";\r\n echo \"\";}\r\n}}\r\n?><\/pre> <\/p>"}
Home
php教程
php手冊(cè)
php基礎(chǔ)教程:文件以二進(jìn)制形式上傳并放入數(shù)據(jù)庫(kù)
php基礎(chǔ)教程:文件以二進(jìn)制形式上傳并放入數(shù)據(jù)庫(kù)
Mar 21, 2017 pm 02:18 PM
upload
binary
database
document
php基礎(chǔ)教程:文件以二進(jìn)制形式上傳并放入數(shù)據(jù)庫(kù)
conn.php: <?php
$id=mysql_connect('localhost','root','root');
mysql_select_db("db_database12",$id);
mysql_query("set names gb2312");
?>
index.php: <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>上傳文件到服務(wù)器</title>
<style type="text/css">
<!--
body {
margin-left: 00px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style></head>
<body>
<table width="385" height="185" border="0" cellpadding="0" cellspacing="0" >
<tr>
<td width="130" height="85"> </td>
<td width="200"> </td>
<td width="55"> </td>
</tr>
<form name="form1" method="post" action="index_ok.php" enctype="multipart/form-data">
<tr>
<td height="40"> </td>
<td align="center" valign="middle">
<input name="file2" type="file" id="file2" size="15" maxlength="150"></td>
<td> </td>
</tr>
<tr>
<td height="30"> </td>
<td align="center"><input type="submit" name="Submit" value="提交"></td>
<td> </td>
</tr>
</form>
<tr>
<td height="30"> </td>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>
index_ok.php: <?php
session_start();
include("conn.php");?>
<?php
if($Submit=="提交"){
$data=date("Y-m-d");
$file_name="file2";
$path = './upfiles/'. $_FILES['file2']['name'];
if (move_uploaded_file($_FILES['file2']['tmp_name'],$path)) {
$query="insert into tb_file2(file_name,file_text,data)values('$file_name','$path','$data')";
$result=mysql_query($query);
if($result=true){
echo "上傳成功!!";
echo "<meta http-equiv=\"Refresh\" content=\"3;url=index.php?lmbs=文件上傳\">";
}else{echo "文件上傳失敗!!";
echo "<meta http-equiv=\"Refresh\" content=\"3;url=index.php?lmbs=文件上傳\">";}
}}
?>
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos
Jul 18, 2024 am 05:48 AM
Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps
Detailed tutorial on establishing a database connection using MySQLi in PHP
Jun 04, 2024 pm 01:42 PM
How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())
How to handle database connection errors in PHP
Jun 05, 2024 pm 02:16 PM
To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.
How to save JSON data to database in Golang?
Jun 06, 2024 am 11:24 AM
JSON data can be saved into a MySQL database by using the gjson library or the json.Unmarshal function. The gjson library provides convenience methods to parse JSON fields, and the json.Unmarshal function requires a target type pointer to unmarshal JSON data. Both methods require preparing SQL statements and performing insert operations to persist the data into the database.
MySQL: Simple Concepts for Easy Learning
Apr 10, 2025 am 09:29 AM
MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.
How to use database callback functions in Golang?
Jun 03, 2024 pm 02:20 PM
Using the database callback function in Golang can achieve: executing custom code after the specified database operation is completed. Add custom behavior through separate functions without writing additional code. Callback functions are available for insert, update, delete, and query operations. You must use the sql.Exec, sql.QueryRow, or sql.Query function to use the callback function.
Oracle's Role in the Business World
Apr 23, 2025 am 12:01 AM
Oracle is not only a database company, but also a leader in cloud computing and ERP systems. 1. Oracle provides comprehensive solutions from database to cloud services and ERP systems. 2. OracleCloud challenges AWS and Azure, providing IaaS, PaaS and SaaS services. 3. Oracle's ERP systems such as E-BusinessSuite and FusionApplications help enterprises optimize operations.
MySQL: An Introduction to the World's Most Popular Database
Apr 12, 2025 am 12:18 AM
MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.
See all articles
|