WHAT I AM TRYING TO DO
- I am uploading multiple files using the following PHP script and am trying to rename files having same names.
- Add a real time progress bar (radial).
PROBLEMS
- I am receiving errors yet my files are being uploaded with the new name.
- Have no idea how to go about having the progress bar to update in real time.
PHP
<?php
if(isset($_FILES['uploadfile'])){
$total_files = count($_FILES['uploadfile']['name']);
if( $total_files > 0){
for($i=0; $i<$total_files; $i++) {
$file_name = $_FILES['uploadfile']['name'][$i];
$file_size = $_FILES['uploadfile']['size'][$i];
$file_tmp = $_FILES['uploadfile']['tmp_name'][$i];
$file_type = $_FILES['uploadfile']['type'][$i];
$upload_Path = "storage/".$file_name;
if($file_size > 8000000){
$errors = 'Total upload size must be less than 8 MB.';
die;
}
if($file_tmp == ""){
$errors = 'There is no file path.';
die;
}
else{
if(!file_exists($upload_Path)){
move_uploaded_file($file_tmp, $upload_Path);
}
else{
$name = pathinfo($file_name, PATHINFO_FILENAME);
$ext = pathinfo($file_name, PATHINFO_EXTENSION);
$new_name = $name.rand().'.'.$ext;
$new_Path = "storage/".$new_name;
rename ($file_tmp, $new_Path);
move_uploaded_file($file_tmp, $new_Path);
}
}
}
}
}
?>
ERRORS
Warning: move_uploaded_file(C:wamptmpphp35CF.tmp): failed to open stream: No such file or directory in C:wampwwwuploadermupld.php on line 36
Warning: move_uploaded_file(): Unable to move 'C:wamptmpphp35CF.tmp' to 'storage/instructions5361.txt' in C:wampwwwuploadermupld.php on line 36
Aucun commentaire:
Enregistrer un commentaire