<?php
$chataudiopath = "uploadss/";
$tmp_dir = "tmp/";
$target_dir = $chataudiopath;
if (!file_exists($target_dir)) {
mkdir($target_dir, 0777, true);
}
$mname = date("Y") . date("m") . date("d");
$tarihPath = $mname . "/";
$new_dir = $chataudiopath . $tarihPath;
if (!file_exists($new_dir)) {
mkdir($new_dir, 0777, true);
copy($chataudiopath . "index.php", $new_dir . "index.php");
}
$target_file = $new_dir . basename($_FILES["file"]["name"]);
$uploadOk = 1;
$fileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
if (isset($_FILES["file"])) {
$check = filesize($_FILES["file"]["tmp_name"]);
if ($check !== false) {
echo "File is an audio file - " . $check . " bytes.";
$uploadOk = 1;
} else {
echo "File is not an audio file.";
$uploadOk = 0;
}
}
if (file_exists($target_file)) {
echo "Sorry, file already exists.";
$uploadOk = 0;
}
if ($fileType != "3gp" && $fileType != "mp3" && $fileType != "wav" && $fileType != "m4a" && $fileType != "aac") {
echo "Sorry, only 3GP, MP3, WAV, M4A, and AAC files are allowed.";
$uploadOk = 0;
}
if ($uploadOk == 0) {
echo "Sorry, your file was not uploaded.";
} else {
if (move_uploaded_file($_FILES["file"]["tmp_name"], $target_file)) {
echo "The file " . htmlspecialchars(basename($_FILES["file"]["name"])) . " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}
}
?>
With this code, I upload 3gp from java and save it to the server.
but it corrupts the file.
You need to wait 30 minutes for it to upload a new file without damaging it.
Why does it give this error? Should I make a setting on the server?
One file is uploaded intact, but all subsequent files are not uploaded properly until about 30 minutes later. I cannot open the files.
Dindaralkolik is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.