I created a website that allow the uploading of files (songs) and everything was working fine but all of a sudden files stopped uploading in my own device but when I used another person's device the file uploaded successfully. It seems when ever a user uploads some files (maybe 10 or 5 or even 4) the upload script will stop working for that particular device irrespective of the browser. I just received a report from a user telling me the same experience. How do I fix this?
$maxsize = 12345678;
$target_dir = "songs/";
$target_file = mysqli_real_escape_string($con,$target_dir . $_FILES["file1"]["name"]);
$fileName = $_FILES["file1"]["name"]; // The file name
$fileTmpLoc = $_FILES["file1"]["tmp_name"]; // File in the PHP tmp folder
$fileType = $_FILES["file1"]["type"]; // The type of file it is
$fileErrorMsg= $_FILES["file1"]["error"]; // 0 for false... and 1 for true
// Select file type
$audioFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
// Valid file extensions
$extensions_arr = array("mp3","wma","wav","ogg");
// Check extension
if( in_array($audioFileType,$extensions_arr) ){
// Check file size
if(($_FILES['file1']['size'] >= $maxsize) || ($_FILES["file1"]["size"] == 0)) {
echo "<h6>Your audio file is too large, please compress your file and try again. </h6>";
}else{
$sql = mysqli_query($con,"SELECT * FROM songs WHERE name = '$fileName' AND location='$target_file'");
$num = mysqli_num_rows($sql);
if($num == 1){
echo "<h6 style='color:red'>Failed to upload file. Possible duplicate<br/>Duplicate error</h6>";
}else{
// Upload
if(move_uploaded_file($fileTmpLoc,$target_file)){
// Insert record
$query = "INSERT INTO songs (name,location,text,username)
VALUES('".$fileName."','".$target_file."','".$text."' ,'".$_SESSION["username"]."')";
mysqli_query($con,$query);
echo "<br />";
echo "<h4>".$fileName." has been uploaded successfully</h4>";
echo "<div class='loader'></div><h6 style='color:green'>Kindly click on the home icon and search your audio
file to ensure it has been uploaded successfully...</h6>";
}
}
}
}else{
echo "<h6></h6>";
}
tag I noticed when I add a text on it when ever I open the upload file page the text will appear at the top of the page so I had to leave it blank
– Dec 06 '19 at 09:13