목차
upload your file
백엔드 개발 PHP 튜토리얼 一个关于文件上传的页面.遇到异常.求大神指导指导

一个关于文件上传的页面.遇到异常.求大神指导指导

Jun 13, 2016 pm 12:48 PM
gt lt name nbsp

一个关于文件上传的页面.遇到错误.求大神指导指导

<br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br />
<html xmlns="http://www.w3.org/1999/xhtml"><br />
<head><br />
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><br />
<title>upload.</title><br />
<style type="text/css"><br />
<!--<br />
.STYLE2 {<br />
	font-family: "宋体";<br />
	font-weight: bold;<br />
}<br />
--><br />
</style><br />
</head><br />
<br />
<body><br />
<style type="text/css"><br />
<!--<br />
tr,td{font-size:10px}<br />
--><br />
</style><br />
<center><br />
	<h1 id="upload-nbsp-your-nbsp-file">upload your file</h1><br />
	<p><br />
	<table border="1" cellspacing="0" cellpadding="1" bordercolordark="#ffffff" bordercolorlight="#0000ff" width="400"><br />
	<form action="up_back.php" method="post" enctype="multipart/form-data"><br />
	<tr bgcolor="#ccccff"><br />
	<td>chose your file:</td><br />
	<td><input type="file" name="upfile" size=32 /></td><br />
	</tr><br />
	<tr><br />
	<td>describe:</td><br />
	<td><input type="text" name="describe" size="42" /></td><br />
	</tr><br />
	<tr><br />
	<td>owner:</td><br />
	<td><input type="text" name="owner" size="42" /></td><br />
	</tr><br />
	<tr><br />
	<td>submit:</td><br />
	<td><center><input type="submit" value="submit" /></center></td><br />
	</tr><br />
	</form><br />
	</table><br />
	</p><br />
</center><br />
	<br />
	<br />
</body><br />
</html>
로그인 후 복사

这个是用来前台的页面调用下面的php.
<br />
<?php<br />
if (!$_POST["upfile"]&&$_FILES["upfile"]["name"]=="")<br />
{<br />
	echo "no file<p>";<br />
	echo "click<a href=\"up_forward.html\">there</a>return!";<br />
}<br />
else <br />
{<br />
	$filepath="upload/";<br />
	$name=$filepath.$_FILES["upload"]["name"];<br />
	while (file_exists($name))<br />
	{<br />
		$temp=explode(".", $name);<br />
		$name=$temp[0]."0".".".$temp[1];<br />
	}<br />
	if(move_uploaded_file($_FILES["upfile"]["tmp_name"], $name))<br />
	{<br />
		if ($_POST["owner"])<br />
		{<br />
			$owner=$_POST["owner"];<br />
		}<br />
		else <br />
		{<br />
			$owner="NULL";<br />
		}<br />
		if ($_POST["describe"])<br />
		{<br />
			$describe=$_POST["describe"];<br />
		}<br />
		else<br />
		{<br />
			$describe="NONE";<br />
		}<br />
		$time=date("y-m-d H:m:s");<br />
		$content=$_FILES["upload"]["name"]."||".$owner."||".$describe."||".$time."\n";<br />
		file_put_contents("record.dat", $content.FILE_APPEND);<br />
		echo "name:".$_FILES["upfile"]["name"];<br />
		echo "<p>";<br />
		echo "is upload successfull.<p>";<br />
		echo "click<a href=\"up_forward.html\">there</a>return!";<br />
	}<br />
	else <br />
	{<br />
		echo "upload error!<p>";<br />
		echo "fail!<p>";<br />
		echo "click<a href=\"index.php\">there</a>check!";<br />
	}<br />
}<br />
?><br />
로그인 후 복사

问题就在于上传之后,提示文件上传成功,但是upload文件夹里面文件名是0的倍数,而且没有文件格式..这个是怎么回事呢?


提示的错误就是下面这些..
Notice: Undefined index: upfile in D:\phpnow\htdocs\b\up_back.php on line 2

Notice: Undefined index: upload in D:\phpnow\htdocs\b\up_back.php on line 10

Notice: Undefined offset: 1 in D:\phpnow\htdocs\b\up_back.php on line 14

본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

뜨거운 기사 태그

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

해결 방법: 조직에서 PIN 변경을 요구합니다. 해결 방법: 조직에서 PIN 변경을 요구합니다. Oct 04, 2023 pm 05:45 PM

해결 방법: 조직에서 PIN 변경을 요구합니다.

Windows 11에서 창 테두리 설정을 조정하는 방법: 색상 및 크기 변경 Windows 11에서 창 테두리 설정을 조정하는 방법: 색상 및 크기 변경 Sep 22, 2023 am 11:37 AM

Windows 11에서 창 테두리 설정을 조정하는 방법: 색상 및 크기 변경

Windows 11에서 제목 표시줄 색상을 변경하는 방법은 무엇입니까? Windows 11에서 제목 표시줄 색상을 변경하는 방법은 무엇입니까? Sep 14, 2023 pm 03:33 PM

Windows 11에서 제목 표시줄 색상을 변경하는 방법은 무엇입니까?

Windows 11/10 복구의 OOBELANGUAGE 오류 문제 Windows 11/10 복구의 OOBELANGUAGE 오류 문제 Jul 16, 2023 pm 03:29 PM

Windows 11/10 복구의 OOBELANGUAGE 오류 문제

Windows 11에서 작업 표시줄 축소판 미리 보기를 활성화 또는 비활성화하는 방법 Windows 11에서 작업 표시줄 축소판 미리 보기를 활성화 또는 비활성화하는 방법 Sep 15, 2023 pm 03:57 PM

Windows 11에서 작업 표시줄 축소판 미리 보기를 활성화 또는 비활성화하는 방법

화웨이 GT3 Pro와 GT4의 차이점은 무엇입니까? 화웨이 GT3 Pro와 GT4의 차이점은 무엇입니까? Dec 29, 2023 pm 02:27 PM

화웨이 GT3 Pro와 GT4의 차이점은 무엇입니까?

Windows 11의 디스플레이 크기 조정 가이드 Windows 11의 디스플레이 크기 조정 가이드 Sep 19, 2023 pm 06:45 PM

Windows 11의 디스플레이 크기 조정 가이드

Windows 11에서 밝기를 조정하는 10가지 방법 Windows 11에서 밝기를 조정하는 10가지 방법 Dec 18, 2023 pm 02:21 PM

Windows 11에서 밝기를 조정하는 10가지 방법

See all articles