I am facing a problem, when I try to upload Audio or Video files to my website they do not upload.
I have added these lines to .htaccess file
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
Worst thing is I ca not even upload audio or video files that are less than 1MB, but other files work like images and text.
I am using dopzone script for upload this is my code for upload:
<?php include("includes/connect.php"); if(!empty($_FILES)) { date_default_timezone_set('Europe/Riga'); session_start(); $token_unhashed = $_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"); $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); } ?>
And this is 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>
Advertisement
Answer
So i figured it out When you try to upload file which contains > ‘ < in name it will not upload so i added this line which changes file name, now everything works
$UploadName_old = $_FILES['file']['name']; $UploadTmp = $_FILES['file']['tmp_name']; $UploadName = str_replace("'", "-", $UploadName_old);