试图为人们提供一个上传文件到此网站的地方。我试的时候出错了。让我知道你的想法。顺便说一句
=====HTML=====
<div id="upload">
<form enctype="multipart/form-data" action="<?=current_url()?>" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" />
<br />
<input type="submit" value="Upload" />
</form>
<p><?=$uploadResult?></p>
</div>
=====PHP=====
if ($this->input->post()) {
$target_path = "../../uploads/";
$target_path = $target_path .basename($_FILES['uploadedfile']['name']);
if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
$uploadResult = "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
} else {
$uploadResult = "There was an error uploading the file, please try again!"; /* <---- Error I get */
}
} else {
$uploadResult = 'didnt work at all';
}
echo $uploadResult;
$this->data['uploadResult'] = $uploadResult;
=====错误=====
遇到PHP错误严重性:警告消息:move_uploaded_file(../../uploads/notes_USH.odt):无法打开流:没有这样的文件或目录文件名:controllers/discovery.php行号:158
确保目录"../../uploads/"存在并且您具有写入权限。PHP不会为你创建这个。
此外,CodeIgnter有一个类来处理文件上传(可能很有用)。你可以在文档中看到这一点。
好吧,这有点晚了,但我只是用代码点火器的东西重新制作了整个东西,经过一些修补,我让它开始工作了。