<input type="file" name="file[]" multiple="multiple" />
<input type="submit" value="上传" />
</form>
<php
$upload_dir = 'uploads/'
if(isset($_FILES) &&!empty($_FILES)){
if(count($_FILES['file']['name'])>1){
for($i=0$i<count($_FILES['file']['name'])$i++){
$tmp_file=$_FILES['file']['tmp_name'][$i]
$file_name=$_FILES['file']['name'][$i]
$file_type=$_FILES['file']['type'][$i]
$file_size=$_FILES['file']['size'][$i]
$file_error=$_FILES['file']['error'][$i]
$upload_file=$upload_dir.$file_name
if(move_uploaded_file($tmp_file,$upload_file)){
echo "上传成功"
}else{
echo "上传失败"
}
}
}else{
}
}
?>
将upload_json.php中的一段改为:
$save_date = date("YmdHis")//新文件名
$new_file_name = $save_date . '_' . rand(10000, 99999) . '.' . $file_ext
//移动文件
$file_path = $save_path . $new_file_name
$savePath .= $new_file_name
if (move_uploaded_file($tmp_name, $file_path) === false) {
alert("上传文件失败。")
}else{
#####存储文件路径#####
$saveDatas = array('path'=>$savePath, 'date'=>$save_date)
$mysql->addFile($saveDatas)
if(!empty($_GET['type'])){
$type = $_GET['type']
header("Location:../list_up_file.php?type={$type}")
}
}
@chmod($file_path, 0644)
$file_url = $save_url . $new_file_name
header('Content-type: text/html charset=UTF-8')
$json = new Services_JSON()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)