我遇到问题,当我尝试将音频或视频文件上传到我的网站时,它们没有上传。
我已将这些行添加到.htaccess文件
php_value upload_max_filesize 1000M
php_value post_max_size 2000M
php_value memory_limit 3000M
php_value max_execution_time 1800
php_value max_input_time 1800
最糟糕的是,我什至没有上传小于1MB的音频或视频文件,但其他文件却可以处理图像和文本。
我正在使用dopzone脚本进行上传,这是我的上传代码:
<?php
include("includes/connect.php");
if(!empty($_FILES))
{
date_default_timezone_set('Europe/Riga');
session_start();
$token_unhashed = $_SESSION['share_token'];
$token = hash('tiger192,3',$_SESSION['share_token']);
$sql_multiple = "SELECT share_token,share_views,share_expire,share_date FROM shares WHERE share_token='$token'";
$result = $conn->query($sql_multiple);
$exist = mysqli_num_rows($result);
if ($exist>=1)
{
$share_views = 0;
$datetime = date('Y-m-d H:i:s');
$expire_time = date("Y-m-d H:i:s", strtotime('+24 hours'));
}
else
{
$share_views = 0;
$datetime = date('Y-m-d H:i:s');
$expire_time = date("Y-m-d H:i:s", strtotime('+24 hours'));
mkdir("web/shares/".$token_unhashed, 0777, true);
}
$UploadName = $_FILES['file']['name'];
$UploadTmp = $_FILES['file']['tmp_name'];
move_uploaded_file($UploadTmp, "web/shares/".$token_unhashed."/$UploadName");
include("includes/generator.php");
$share_uid = hash('tiger192,3',$share_uid);
$sql = "INSERT INTO shares (share_token,share_uid,share_views,share_downloads,share_name,share_expire,share_date)
VALUES ('$token','$share_uid','$share_views','0','$UploadName','$expire_time','$datetime')";
include("includes/logs.php");
$ip = $_SERVER['REMOTE_ADDR'];
$address = ip_info($ip, "address");
$browser = get_browser_name($_SERVER['HTTP_USER_AGENT']);
$os = getOS($_SERVER['HTTP_USER_AGENT']);
$sql_logs = "INSERT INTO share_logs (ip,upload_name,browser,os,address,date)
VALUES ('$ip','$UploadName','$browser','$os','$address','$datetime')";
$sql_update_total_uploads = "UPDATE stats SET total_uploads=total_uploads+1";
mysqli_query($conn, $sql_update_total_uploads);
mysqli_query($conn,$sql);
mysqli_query($conn,$sql_logs);
mysqli_close($conn);
}
?>
这是html:
<div class='upload-panel c' style='margin-top: 40px;'>
<form enctype="multipart/form-data" action="upload.php" class="f-c upload dropzone">
<div class="b s-22 dz-message needsclick">
<i class='fa fa-cloud-upload-alt s-50' aria-hidden='true'></i>
<div>Drop files here or click to upload.</div>
</div>
</form>
</div>
Uou可以实时检查它:https://sharefast.me/
答案 0 :(得分:0)
所以我想通了 当您尝试上传名称中包含>'<的文件时,它将不会上传,因此我添加了此行来更改文件名,现在一切正常
$UploadName_old = $_FILES['file']['name'];
$UploadTmp = $_FILES['file']['tmp_name'];
$UploadName = str_replace("'", "-", $UploadName_old);