我前段时间编写了这段代码,它运行正常,但突然停止工作, 该代码似乎无法检索上载文件的名称,但是,如果我将该名称更改为文件的其他属性(如大小和类型),则效果很好。任何帮助,将不胜感激。谢谢
我知道问题不在于html文件,所以我没有包括在内。我这样说的原因是, 其他文件属性(例如大小和类型)也可以很好地工作,事实上,同一段代码在一段时间之前就可以正常工作。
<?php
try{
include("dbconnect.php");
if(isset($_POST['uploadbtn'])){
$code = $_POST['code'];
$atname = trim($_POST['artistname']);
$stittle = trim($_POST['songtittle']);
$dcription = trim($_POST['describe']);
$songtittle = filter_var($stittle,FILTER_SANITIZE_STRING);
$artistname = filter_var($atname,FILTER_SANITIZE_STRING);
$description = filter_var($dcription,FILTER_SANITIZE_STRING);
$name = $_FILES['audio']['name'];
$imname = $_FILES['image']['name'];
try{
mysqli_query($connect,"INSERT into musicfiles (music_id,uploadCode,artistName,songTittle,audio,image,fileDescription) VALUES ('','$code','$artistname','$songtittle','$name','$imname','$description')") or die("error");
echo "entered successfully";
}
catch(Exception $error){
echo "".$error;
}
}
}
catch(Exception $exe){
echo "".$exe;
}
mysqli_close($connect);
?>
答案 0 :(得分:0)
$_FILES['name_of_your_input']['name']
或检查您的表单是否需要
<form enctype="multipart/form-data" action="__URL__" method="POST">