J
J
JyriG2021-07-03 22:35:00
PHPMailer
JyriG, 2021-07-03 22:35:00

How can I prevent the file upload script from downloading a file twice in a row?

Problem:

I have a script from the plupload library that uploads files to the server in small parts in the specified folder, and at the moment the problem is that the mail sender script used to be responsible for this:

$total_count7 = count($_FILES['file-7']['name']);
    // Loop through every file
    for( $i=0 ; $i < $total_count7 ; $i++ ) {
       //The temp file path is obtained
       $tmpFilePath = $_FILES['file-7']['tmp_name'][$i];
       //A file path needs to be present
       if ($tmpFilePath != ""){
          //Setup our new file path
          $newFilePath = "./uploads/" . $_FILES['file-7']['name'][$i];
          //File is uploaded to temp dir
          if(move_uploaded_file($tmpFilePath, $newFilePath)) {
          		$mail->addAttachment("uploads/" . $_FILES['file-7']['name'][$i]);
          }
       }
    }


Which is now useless as it downloads the file a second time. How to make sure that this piece of code does not download the file a second time, but takes the file uploaded by the client from the specified folder?

(libraries used are phpmailer and pluploader).
I hope to help!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question