The fact is that in general everything works, worked with some files, less and more than 5 MB. Everything worked, the script responded, but then decided to check other files, more than 10mb the script displays what is loaded, why? I checked about 10 files with a size of more than 5 MB, some downloads and some do not. I checked this in chrome, and in mozilla firefox I generally load a file less than 5 MB, the answer is that it is more than 5 MB. What kind of garbage? Here is the handler

if($_FILES['myfile']){ if(file_type($_FILES['myfile']['type']) AND $_FILES['myfile']['size'] < 5242880){ $dir = "../demo/"; $file_name = date("dyHmis"); $file_type = file_type($_FILES['myfile']['type']); if(move_uploaded_file($_FILES['myfile']['tmp_name'], "$dir$file_name$file_type")){ $namemuz = $_FILES['myfile']['name']; $str = substr($namemuz, 0, -4); $direct = "http://mackay.kz/music/demo/"; $urltrack = "$direct$file_name$file_type"; mysql_query("INSERT INTO `mackaykz_music`.`demos` (`namedemo`, `link`) VALUES ('$str', '$urltrack');"); } }else{ echo 'недопустимо'; } } 

Here is js

  onComplete : function(file, result) { if(result == "недопустимо"){ $("#uploadtrack").text('Загрузка трека'); $("#filemassage").html('Извините, но файл привышает размер 5 мб.'); this.enable(); }else{ $("#uploadtrack").text('Загрузка трека').animate({position: 'relative', top: '-45px'},60); $("#sendermodalwin").fadeIn(50).animate({position: 'relative', top: '-54px'},60); var str = file.substring(0, file.length - 4); $('#namedemostrokes').text(str); $("#filemassage").html('Демка была загружена: <br>' + str +' <br><audio autoplay controls src="' + result +'" ></audio>'); $("#linkdemomain").text(result); this.enable(); } } 

    1 answer 1

    Check

     $_FILES['myfile']['error'] 

    It contains an error code, which means the download was not completed, so the file size is 0, which is less than 5 million by the verification condition.
    In addition, your code is vulnerable to SQL injection in two places: you can transfer anything to filename and mime. Check this data before inserting it into a database query.

    • I know about the injection, I want to sort out the download first, then I will consider the PDO. Now everything works in chrome, but the mace also downloads a file of less than 5mb and says that it is more than 5mb, although everything is ok in chrome. Why is that? - trix