1

I just knew that upload.php file will run for each uploaded file. So when if there are 5 files, the upload.php will run 5 times right?

I need to insert a record into mysql 'album' table so that I can get the albumid to be inserted into the 'photos' table.

My idea is to run a script before the upload starts.

How is that possible with plupload? Or any different idea guys?

Or to the root question, is there any way to specify the album for the uploaded photos?

Thanks

Redzwan Latif
  • 886
  • 3
  • 14
  • 38
  • Not sure of what you want to achieve, but it seems you want to pass additional parameters. Maybe this can be of some help : http://stackoverflow.com/a/13382331/1236044 – jbl Feb 11 '13 at 13:21
  • Nope. I need to run a script before the upload. if I put the insert album statement in the upload.php, there will be many album if there are many photos uploading. I just want to create a single album. Thanks :D – Redzwan Latif Feb 11 '13 at 13:24

1 Answers1

1

I guess you could :

  1. have a client-side variable albumId, default empty
  2. bind to the BeforeUpload uploader event
  3. in BeforeUpload handler, see if AlbumId is set. If not, perform a synchronous ajax call to create an album and retrieve its albumId, you will put in variable albumId
  4. still in BeforeUplad handler, add the albumId in the queryParameters : upldr.settings.url = upldr.settings.url + '&albumId=' + albumId

I guess it should work, without having to use any kind of locking mechanism on albumId.

Hope this will help.

jbl
  • 15,179
  • 3
  • 34
  • 101
  • Thank you very much :D . Thanks for the flow, Just one confussion remaining, what you mean by "perform a synchronous ajax call to create an album". Does it mean that I have to use ajax to insert row to mysql 'album' table? or does it mean that I have to run a php script first using ajax? sorry to ask that kind of question but I'm still new to jquery , ajax etc. . Thanks :D – Redzwan Latif Feb 11 '13 at 14:51
  • @RedzwanLatif : it means doing a http://api.jquery.com/jQuery.ajax/ call from your client to a server side php script, with async option set to false. Your php script will perform album insertion and return the insert album id ( in json format which is easier to process). The returned id will be processed in the success handler of your ajax call. – jbl Feb 11 '13 at 15:18