Pass a parameter to upload-many.php and rename

Pass a parameter to upload-many.php and rename

classic12classic12 Posts: 228Questions: 60Answers: 4

Hi guys,

I have a database table that has a quoteID auto inc field.
I want to add a few images / files at a time but rename them as quoteID+-01.jpg quoteID+-02.jpg quoteID.xls

So I need to get the current quoteID ( Column 0 ) pass this then rename the files. 501-01.png 501-02.jpg 501-03.xls

I know how to read at parameter in PHP using $GET so

  1. Read the current quoteID
  2. How do I pass the parameter.
  3. Then do the renaming in the PHP file.

Cheers

Steve Warby

Answers

  • allanallan Posts: 61,822Questions: 1Answers: 10,127 Site admin

    Hi Steve,

    The issue there is that the field upload happens before the main row is created. So in this case when the files are uploaded there would be no quoteID as it doesn't exist yet! That's the reason why the examples don't show the host row id being used in the file name.

    I'm assuming that the quote ID being in the file name that is downloaded is a system requirement - the only way I think that would work at the moment is to have the files named per the files ID table (like in the examples) and when the download request is made, proxy it through a PHP script that will download a file with the required name (i.e. look up the database to find what quote is using the file requested and get the quote id).

    Regards,
    Allan

  • classic12classic12 Posts: 228Questions: 60Answers: 4

    Hi Allan,

    I am using

          var selectedQuoteID;
          $('#dtQuotes').on( 'select.dt', function ( e, dt, type, indexes ) {
          //var data = dt.rows(indexes).data();
          selectedQuoteID = table.cell('.selected', 0).data();
          console.log('selectedQuoteID = '+ selectedQuoteID);
          
            } );
    

    So I have a global var selectedQuoteID. Can this be using in the editor before the choose file / drag file action ?

    Cheers

    Steve Warby

  • allanallan Posts: 61,822Questions: 1Answers: 10,127 Site admin

    But my point is that you can't have that when you are creating a new row. The id for the new row isn't created until you submit the new form data to the server. By which time the files have already been uploaded.

    Allan

This discussion has been closed.