This topic is locked

Upload Multiple Files And Split Them Into Different Records

6/11/2013 6:51:14 AM
PHPRunner General questions
I
indigo author

Hi,
I have a table with File upload field.

I like the ability to upload multiple files from a single control field in the new PHPR.
Is it possible to upload multiple in one table sat 'tableA' and then explode them in 'tableB' in separate records?

Similar to "Insert record" event that we use in PHPR events (After Add/Edit)

Though I can do this for other fields, I am not sure how to do this for uploaded files.
One more request, how to I extract & save file attributes in different fields for e.g. file extension, file size, file date etc?

Sergey Kornilov admin 6/11/2013

Yes, this is possible. In your AfterEdit event you need to parse the JSON format PHPRunner uses to store multiple files data and insert as amny records into tableB as the number of files were uploaded.
Here is the code sample that explains how to parse this format:

http://xlinesoft.com/phprunner/docs/rename_uploaded_file.htm
It gives you access to file size/extension as well.

I
indigo author 7/4/2013

Hi,
I have completed this and I am able to split the files in multiple records.
I want to achieve 2 things:

  1. When user deletes any of those new records in tableB, the file also should get deleted.
  2. The user should get a link to download the files from the application, but no direct download outside the application should be allowed.
    Whats the best way to get these things done?

Sergey Kornilov admin 7/5/2013

Second part is easy - you need to choose upload folder that is outside of your website root directory. In this case nobody will be able to download files directly. For instance your website root directory is C:\Inetpub\wwwroot\yourwebsite.com\public_html. If you choose C:\Inetpub\wwwroot\yourwebsite.com\files as upload directory you prevent direct access to uploaded files.
The first request is a bit more complicated. You need to implement BeforeDelete event to delete corresponding file manually.