Home >Backend Development >PHP Tutorial >HP pavilion dv1000 allows you to upload 1000 files at the same time (2)
Now that the file submission page has been generated, the following task is clear: save the submitted file content to the server.
Below we use two methods to implement this function:
1. Use PHP to save:
We first define a file saving function fup() which has two parameters:
$filename: file content
$fname: file name ( including the path)
All that's left is to write a loop to write the files to the server one after another. Here is a brief explanation:
PHP handles uploaded files like this: If the submitted file box is file0, then the content of the file submitted to PHP is stored in the variable $file0, and the file name is stored in $file0_name. In this way, what I have to do in this loop is to decompose the content submitted on the submission page. Please see the code below for the implementation process.
fileup.php
------------------------------------------------ ------------------------
function fup($filename,$fname)
{ If($filename != "none" ]
$i;
$ffnnname=$ffnn."_name";
fup ($$ffnn,$$ffpath.$$ffnnname); //"../www/test/tmp/"
}
?>
-------------------------------- -------------------------------------------------- ----
2. Use PERL to save:
The principles of their implementation are exactly the same, I won’t go into details here, please look at the code:
fileup.cgi(fileup.pl)
---------- -------------------------------------------------- ----------
#!/usr/bin/perl
use CGI qw/:standard/;
if ($ENV{'CONTENT_TYPE'} !~ /multipart/form-data/) {
print "Cache-Control: no-cachenPragma: no-cachen" .
"Content-Type: text/htmlnn" .
"