파일을 업로드하는 데 문제가 있습니다. 내 메인 페이지에 이제파일 업로드에 문제가 발생했습니다.
class upload
{
private $name;
private $document;
public function __construct($nme,$doc)
{
$this->setName($nme);
$this->setDocument($doc);
}
public function setName($nme)
{
$this->name = $nme;
}
public function setDocument($doc)
{
$this->document = $doc;
}
public function fileNotPdf()
{
/* Was the file a PDF? */
if ($this->document['type'] != "application/pdf")
{
return true;
}
else
{
return false;
}
}
public function fileNotUploaded()
{
/* Make sure that the file was POSTed. */
if (!(is_uploaded_file($this->document['tmp_name'])))
{
return true;
}
else
{
return false;
}
}
public function fileNotMoved($repositry)
{
/* move uploaded file to final destination. */
$result = move_uploaded_file($this->document['tmp_name'],
"$repositry/$this->name.pdf");
if($result)
{
return false;
}
else
{
return true;
}
}
}
:
$docName = $_POST['name'];
$page = $_FILES['doc'];
if($_POST['submit'])
{
/* Set a few constants */
$filerepository = "np";
$uploadObj = new upload($docName, $page);
if($uploadObj->fileNotUploaded())
{
promptUser("There was a problem uploading the file.","");
}
elseif($uploadObj->fileNotPdf())
{
promptUser("File must be in pdf format.","");
}
elseif($uploadObj->fileNotMoved($filerepository))
{
promptUser("File could not be uploaded to final destination.","");
}
else
{
promptUser("File has been successfully uploaded.","");
}
}
내가 얻는 오류 :
경고 : 우선 나는 수업이 인 move_uploaded_file을 (about.pdf를) [function.move-uploaded-file] : 스트림을 열지 못했습니다. 해당 파일이나 디렉토리가 없습니다 ...
경고 : 인 move_uploaded_file() 업로드 function.move-파일] : 수 없습니다에서 ...
파일 'about.pdf'에 '\ XAMPP \ TMP \ php13.tmp C'를 이동할 수 없습니다 최종 도착지에 업로드되었습니다.
코드 서식을 수정하십시오. 한 번 더 들여 쓰기해야합니다. –
대상이 쓰기 가능합니까? – SeanJA