预备知识:Javascript, PHP(少量)/Perl(少量)!
测试环境:Windows2000 + IIS5 + PHP (Win98 + PWS + PHP3 失败,估计是配置出了问题)
目录结构:
/wwwroot/cgi-bin/fileup.php (文件接收)
/wwwroot/www/test/phpfileup.htm (文件提交)
/wwwroot/www/test/tmp/ (默认保存目录)
前言:文件上传,简单又麻烦。下面是上传文件的提交页面,利用该页面你不仅可以生成 1000 个上传文件框(实际是任意多个 0~n ),而且可分别指出它们的保存路径。
提交页面的文件输入框为命名为: file0,file1,...file100,...fileN
提交页面的文件路径框为命名为: path0,path1,...path100,...pathN
由于页面的生成非常简单,所以就不在此多解释了,用 javascript 定义了两个函数,check() 用于提交页面,create()用于生成文件上传框。如果你有什么更好的建议或有什么疑问请 Email: gearsoft@netease.com
phpfileup.htm
--------------------------------------------------------
请输入要上传文件的数量:
文件提交页面既已生成,下面任务就很明确了:将提交的文件内容保存到服务器上。
下面我们用两种方法来实现这个功能:
1. 用 PHP 来保存:
我们先定义一个文件保存函数 fup() 它有两个参数:
$filename: 文件内容
$fname: 文件名(包含路径)
剩下的就是写一个循环将文件依次写入服务器。这里要简单说明一下:
PHP 对于上传文件的处理是这样的:如果提交的文件框我为 file0, 那么提交给 PHP 的文件内容保存在变量 $file0 中,而文件名则保存在 $file0_name 中。这样在这个循环中我要做的就是将提交页面提交的内容分解出来,实现过程请看下面的代码。
fileup.php
----------------------------------------------------------------------
function fup($filename,$fname)
{ If($filename != "none") {
copy($filename,$fname);
unlink($filename);
}
}
for($i=0;$i{
$ffnn="file".$i;
$ffnnname=$ffnn."_name";
$ffpath="path".$i;
//print $$ffnn;
print $$ffnnname;
print "
";
fup($$ffnn,$$ffpath.$$ffnnname); //"../www/test/tmp/"
}
?>
----------------------------------------------------------------------
2. 用 PERL 来保存:
它们实现的原理完全一样,在此不多说,请看代码:
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" .
"
exit 0;
}
$cntfile=param(cnt);
print header;
print start_html;
#print "Receiving Please wait....";
&g_head;
#$writed = ../www/test/tmp/;
for ($i=0;$i$paramfile = file.$i;
$parampath=path.$i;
$writed=param($parampath);
&upfile;
&g_body;
}
&g_bott;
#
sub upfile
{
$maxdata = 512000;
# $writed = ../www/test/tmp/;
$strRFname=reverse $xfile;
$intIndex=index($strRFname,);
$strNetFname=substr($strRFname,0,$intIndex);
$strNetFname=scalar reverse $strNetFname;
if((stat $xfile)[7]>$maxdata){
print "Status: 411 Size Not Allowedn" .
"Content-Type: text/htmlnAllow: POSTnn" .
"
You got big problem. Try again.
n";exit 0;
}
binmode $xfile;
use File::Copy;
copy($xfile,$writed.$strNetFname);
}
sub g_head{
print
文件上传结果(Upload Result) | ||
SourceFile: | ;DestFile: | ;Upload | ;
.$xfile . | ;.$writed.$strNetFname. | ;OK! | ;
}
----------------------------------------------------------------------
如有好的建议请 Email: gearsoft@netease.com

wpsystem文件夹是windows应用文件夹;创建WpSystem文件夹是为了存储某些特定“Microsoft Store”应用程序的数据,因此建议不要删该文件夹,因为删除之后就无法使用指定的应用。

winreagent是在系统更新或升级的过程中创建的文件夹;该文件夹中通常包含临时文件,当更新或升级失败时,系统将通过还原先前创建的临时文件来回滚到执行更新或升级过程之前的版本。

baidunetdiskdownload是百度网盘默认下载文件的文件夹;百度网盘是百度推出的一项云存储服务,只要下载东西到百度网盘里,都会默认保存到这个文件夹中,并且可跨终端随时随地查看和分享。

“usmt.ppkg”是windows自带的系统还原功能的系统备份文件;Windows系统还原是在不需要重新安装操作系统,也不会破坏数据文件的前提下使系统回到原有的工作状态,PBR恢复功能的备份文件就是“usmt.ppkg”。

如何在FastAPI中实现文件上传和处理FastAPI是一个现代化的高性能Web框架,简单易用且功能强大,它提供了原生支持文件上传和处理的功能。在本文中,我们将学习如何在FastAPI框架中实现文件上传和处理的功能,并提供代码示例来说明具体的实现步骤。首先,我们需要导入需要的库和模块:fromfastapiimportFastAPI,UploadF

备份文件的扩展名通常是“.bak”;bak文件是一个备份文件,这类文件一般在'.bak前面加上应该有原来的扩展名,有的则是由原文件的后缀名和bak混合而成,在生成了某种类型的文件后,就会自动生成它的备份文件。

随着数字化时代的到来,音乐平台成为人们获取音乐的主要途径之一。然而,有时候我们在听歌的时候,发现没有歌词是一件十分困扰的事情。很多人都希望在听歌的时候能够显示歌词,以便更好地理解歌曲的内容和情感。而QQ音乐作为国内最大的音乐平台之一,也为用户提供了上传歌词的功能,使得用户可以更好地享受音乐的同时,感受到歌曲的内涵。下面将介绍一下在QQ音乐上如何上传歌词。首先

1、打开酷狗音乐,点击个人头像。2、点击右上角设置的图标。3、点击【上传音乐作品】。4、点击【上传作品】。5、选择歌曲,然后点击【下一步】。6、最后点击【上传】即可。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.