The program cannot be used after PHPnow is installed. & nbsp; (2) upload. php & nbsp; --- & nbsp; brief description & nbsp; Upload interface. select a file and submit it to submit. php processing & nbsp; it is worth noting that the program cannot be used after PHPnow is installed.
//////////////////////////////////////// //////////////////////////////
(2) upload. php ---
// Brief description
Upload interface. select a file and submit it to submit. php for processing.
It is worth noting that a hidden VALUE range of MAX_FILE_SIZE can be set
To limit the size of the uploaded file.
// Program source code
File upload form
Method = 'post'>
| Select Upload file |
|
Type = 'submit '> |
(3) submit. php ---
// Brief description
Save the basic information of uploaded files and files to the database.
// Program source code
If ($ myfile! = "None" & $ myfile! = "") {// Upload a file
// Set the time-out period. The default time is 30 seconds. if the value is set to 0, the time-out period is not limited.
$ Time_limit = 60;
Set_time_limit ($ time_limit );//
// Read the file content to the string
$ Fp = fopen ($ myfile, "rb ");
If (! $ Fp) die ("file open error ");
$ File_data = addslashes (fread ($ fp, filesize ($ myfile )));
Fclose ($ fp );
Unlink ($ myfile );
// File format, name, size
$ File_type = $ myfile_type;
$ File_name = $ myfile_name;
$ File_size = $ myfile_size;
// Connect to the database and save the file to the database
$ Conn = mysql_connect ("127.0.0.1 ","***","***");
If (! $ Conn) die ("error: mysql connect failed ");
Mysql_select_db ("test", $ conn );
$ SQL = "insert into receive
(File_data, file_type, file_name, file_size)
Values ('$ file_data', '$ file_type', '$ file_name', $ file_size )";
$ Result = mysql_query ($ SQL );
// The following sentence retrieves the id of the insert statement.
$ Id = mysql_insert_id ();
Mysql_close ($ conn );