1

I am using Fine Uploader for uploading multiple files. It's working fine. But i want a little bit change.

I have a file name upload.php in which i have written a file uploading script in database. I just want that after hitting upload button the request will go to my upload.php file and the files will be uploaded accordingly.

How i can achieve this ?

index.php

<script type="text/template" id="qq-template-manual-trigger">

 <div class="buttons">
    <div class="qq-upload-button-selector qq-upload-button">
         <div>Select files</div>
    </div>

<button type="button" id="trigger-upload" class="btn btn-primary">
      <i class="icon-upload icon-white"></i> Upload
</button>

</div>
 </script>

Javascript

   <script>
        var manualUploader = new qq.FineUploader({
            element: document.getElementById('fine-uploader-manual-trigger'),
            template: 'qq-template-manual-trigger',
            request: {
                endpoint: '/server/upload.php'
            },
            thumbnails: {
                placeholders: {
                    waitingPath: '/source/placeholders/waiting-generic.png',
                    notAvailablePath: '/source/placeholders/not_available-generic.png'
                }
            },
            autoUpload: false,
            debug: true
        });

        qq(document.getElementById("trigger-upload")).attach("click", function() {
            manualUploader.uploadStoredFiles();
        });
    </script>

upload.php

<?php

require_once './include/db_connection.php';

if(!empty($_FILES)){

    $targetDir = "upload/";
    $fileName = $_FILES['file']['name'];
    $targetFile = $targetDir.$fileName;

   if(move_uploaded_file($_FILES['file']['tmp_name'],$targetFile))

   {
        //insert file information into db table
 $sql = mysqli_query($link,"INSERT INTO files (file_name, uploaded) VALUES('".$fileName."','".date("Y-m-d H:i:s")."')");
    }
    else
    {
        echo 'Query not working';
    }

}
  • I'm not grasping here. – Funk Forty Niner Jun 07 '16 at 18:09
  • exactly; I don't understand the question. You say it's working but you state: *"I just want that after hitting upload button the request will go to my upload.php file and the files will be uploaded accordingly. How i can achieve this ?"* - Achieve what exactly? Do you mean "redirect" after it uploaded? – Funk Forty Niner Jun 07 '16 at 18:11
  • Yes, on hitting upload button, the request will redirect to upload.php – bc110402307 Syed Zeeshan Haide Jun 07 '16 at 18:12
  • See this Q&A on Stack http://stackoverflow.com/questions/768431/how-to-make-a-redirect-in-php - you have a few options. This most likely being a possible duplicate of it. – Funk Forty Niner Jun 07 '16 at 18:13
  • Sir, i don't know where to write the redirection code . I am using this plugin for the very first time. I don't know that what piece of code makes uploading – bc110402307 Syed Zeeshan Haide Jun 07 '16 at 18:15
  • simply place the redirection just below the `$sql = mysqli_query($link,"INSERT INTO files...` if the query is successful. – Funk Forty Niner Jun 07 '16 at 18:16
  • no no no.. wait. I am using this plugin for the very first time. When i clicked on upload button, i even don't know how this handles uploading. After reading documentation i came to know that in javascript, by changing the "endPoint" you can handle the uploading. In "endPoint", i mentioned my filename like "uplod.php" but the code is not working – bc110402307 Syed Zeeshan Haide Jun 07 '16 at 18:20
  • on hitting upload button. the upload.php code should run. But this time, i don't know from where and which piece of code is running – bc110402307 Syed Zeeshan Haide Jun 07 '16 at 18:25

0 Answers0