php上传如何设置才能上传压缩包跟txt文本

2024-12-17 23:23:24
推荐回答(4个)
回答1:







网页教学网(webjx.com)文件上传实例



















function getname($exname){

$dir = "../uploadfile/";

$i=1;

if(!is_dir($dir)){

mkdir($dir,0777);

}

while(true){

if(!is_file($dir.$i.".".$exname)){

$name=$i.".".$exname;

break;

}

$i++;

}

return $dir.$name;

}

$exname=strtolower(substr($_FILES['upfile']['name'],(strrpos($_FILES['upfile']['name'],'.')+1)));

$uploadfile = getname($exname);

if (move_uploaded_file($_FILES['upfile']['tmp_name'], $uploadfile)) {

echo "

文件上传成功!



";

}else {

echo "

文件上传失败!



";

}

echo "下面是文件上传的一些信息:



原文件名:".$_FILES['upfile']['name'] .

"

类型:" .$_FILES['upfile']['type'] .

"

临时文件名:".$_FILES['upfile']['tmp_name'].

"

文件大小:".$_FILES['upfile']['size'] .

"

错误代码:".$_FILES['upfile']['error'];
?>
一般文件都是可以传的!文件太大就不行了!

回答2:

用php 代码上传一个压缩包跟txt文件,在页面里面输出内容
上传一个txt文件包含如下信息
* tension
There's an indefinable air of tension at the meeting.
The tension in the Far East is building up again.
* reputation
She had a reputation for punctuality.
This restaurant has a fine reputation.
页面输出
tension$There's an indefinable air of tension at the meeting.
reputation$She had a reputation for punctuality.
PS:思路应该是先用“*”分割内容。然后在采集第一行的单词,及此单词下的第一句句子。

回答3:

PHP本身不能上传啊,需要HTML来上传
PHP只是接收文件。





action是你提交之后的PHP文件,input中的name是你提交之后的变量名称。

回答4:

js验证一次,php验证一次