我想在我的系统上创建一个上传功能,但即使我还没有选择文件,网页上也会显示一条消息。谁能帮我? 这是我的代码:
附件:
<td><form action="upload_file.php" method="post" enctype="multipart/form-data">
<input type="file" name="reservation_Attachment" size="50" />
<br />
<input type="submit" value="Upload" />
</form>
<?php
$targetfolder = "attachment/";
$targetfolder = $targetfolder . basename( $_FILES['reservation_Attachment']['name']) ;
if(move_uploaded_file($_FILES['reservation_Attachment']['tmp_name'], $targetfolder))
{
echo "The file ". basename( $_FILES['reservation_Attachment']['name']). " is uploaded";
}
else {
echo "Problem uploading file";
}
?>
<?php
$targetfolder = "attachment/";
$targetfolder = $targetfolder . basename( $_FILES['reservation_Attachment']['name']) ;
$ok=1;
$file_type=$_FILES['reservation_Attachment']['type'];
if ($file_type=="application/pdf" || $file_type=="image/gif" || $file_type=="image/jpeg") {
if(move_uploaded_file($_FILES['reservation_Attachment']['tmp_name'], $targetfolder))
{
echo "The file ". basename( $_FILES['reservation_Attachment']['name']). " is uploaded";
}
else {
echo "Problem uploading file";
}
}
else {
echo "You may only upload PDFs, JPEGs or GIF files.<br>";
}
?></td>
</tr>
以下是错误:
注意:未定义索引:reservation_Attachment in 第210行的C:\ xampp \ htdocs \ sportvenuereservation \ reservation_form.php
注意:未定义索引:reservation_Attachment in 第211行的C:\ xampp \ htdocs \ sportvenuereservation \ reservation_form.php 问题上传文件注意:未定义的索引:reservation_Attachment 在C:\ xampp \ htdocs \ sportvenuereservation \ reservation_form.php上线 222
注意:未定义索引:reservation_Attachment in 第224行的C:\ xampp \ htdocs \ sportvenuereservation \ reservation_form.php 您只能上传PDF,JPEG或GIF文件。