\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手冊
php基礎(chǔ)教程:文件以二進制形式上傳并放入數(shù)據(jù)庫
php基礎(chǔ)教程:文件以二進制形式上傳并放入數(shù)據(jù)庫
Mar 21, 2017 pm 02:18 PM
upload
binary
database
document
php基礎(chǔ)教程:文件以二進制形式上傳并放入數(shù)據(jù)庫
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
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 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.
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.
MySQL vs. Other Databases: Comparing the Options
Apr 15, 2025 am 12:08 AM
MySQL is suitable for web applications and content management systems and is popular for its open source, high performance and ease of use. 1) Compared with PostgreSQL, MySQL performs better in simple queries and high concurrent read operations. 2) Compared with Oracle, MySQL is more popular among small and medium-sized enterprises because of its open source and low cost. 3) Compared with Microsoft SQL Server, MySQL is more suitable for cross-platform applications. 4) Unlike MongoDB, MySQL is more suitable for structured data and transaction processing.
MySQL: A Beginner-Friendly Approach to Data Storage
Apr 17, 2025 am 12:21 AM
MySQL is suitable for beginners because it is easy to use and powerful. 1.MySQL is a relational database, and uses SQL for CRUD operations. 2. It is simple to install and requires the root user password to be configured. 3. Use INSERT, UPDATE, DELETE, and SELECT to perform data operations. 4. ORDERBY, WHERE and JOIN can be used for complex queries. 5. Debugging requires checking the syntax and use EXPLAIN to analyze the query. 6. Optimization suggestions include using indexes, choosing the right data type and good programming habits.
See all articles
|