I have created a upload file form. It's working fine but i am not able to check whether files exists or not. if it does then it should be renamed automatically.
HTML CODE :-
<form id="upload_form" enctype="multipart/form-data" method="post">
<input type="file" name="file1" id="file1"><br>
<input type="button" value="Upload File" onclick="uploadFile()">
<progress id="progressBar" value="0" max="100" style="width:300px;"></progress><br><br>
Below is the direct link to file :-
<h3 id="status"></h3>
<p id="loaded_n_total"></p>
</form>
PHP CODE :-
<?php
$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
$fileSize = $_FILES["file1"]["size"]; // File size in bytes
$fileErrorMsg = $_FILES["file1"]["error"]; // 0 for false... and 1 for true
if (!$fileTmpLoc) { // if file not chosen
echo "ERROR: Please browse for a file before clicking the upload button.";
exit();
}
if(move_uploaded_file($fileTmpLoc, "upload/$fileName")){
echo "$fileName uploaded";
} else {
echo "move_uploaded_file function failed";
}
?>