Create dynamic upload path for upload using php GET data

I'm writing an intranet manager (so it won't be accessible at all from the internet and will only run locally). I am using "Upload" http://www.uploadify.com/documentation/ , a jQuery script to add files to every customer record (it is used in the store, so the store can add photos / measurement information for carpet customers).

I am using the following settings in the header of my index.php to call the jquery loader. What can I not work out how to add a dynamic download folder to it? He needs to do the following:

'folder'    : './customer-files/<?php $_GET['cfid'] ?>',

      

Is it possible to mix jquery and php like this? What it should do is replace the cfid stored in the GET with the actual client id number for example. / customer -files / 22

<script type="text/javascript" src="./uploadify/swfobject.js"></script>
<script type="text/javascript" src="./uploadify/jquery.uploadify.v2.1.4.min.js">   </script>
<script type="text/javascript">
// <![CDATA[
$(document).ready(function() {
  $('#customeraddnewfile').uploadify({
    'uploader'  : './uploadify/uploadify.swf',
    'script'    : './uploadify/uploadify.php',
    'cancelImg' : './uploadify/cancel.png',
    'folder'    : './customer-files',
   'auto'      : true
  });
});
// ]]>
</script>

      

+3


source to share


2 answers


The best way to do this is to pass an additional parameter using scriptData (your client id and probably some security token that you can check) and then edit the PHP script to find the user, create a folder if it doesn't already exist, and then download the file to this location. Bypassing the need to use the attribute folder

.

<script type="text/javascript">
// <![CDATA[
$(document).ready(function() {
  $('#customeraddnewfile').uploadify({
    'uploader'  : './uploadify/uploadify.swf',
    'script'    : './uploadify/uploadify.php',
    'cancelImg' : './uploadify/cancel.png',
    'folder'    : './customer-files',
    'scriptData': {'cust_id':1234},
    'auto'      : true
  });
});
// ]]>
</script>

      



Without your PHP script, I cannot help in more detail.

0


source


Don't post your data with scriptData.you can use formData.



0


source







All Articles