Get KoolPHP UI with 30% OFF!

Add prefix to uploaded files

michael
I'm writing a multi-upload php script and I need to add the string "USERID_"to each uploaded filename where USERID is the actual userid of my application: (e.g. WA9SRV_uploadedfiilename.adi).
Is there an easy way to do this?
It looks like the Javascript below might do the trick, but I can't figure out how to use it or where to place it in my PHP application. My PHP code pretty much follows the Multi Upload example.
<script type="text/javascript">
kul.registerEvent("OnBeforeUpload",function(sender,arg){
//Attach the folder information before the file is uploaded.
//This info will able to achieve at server-side by $_POST["folder"]
var item = kul.getItem(arg.ItemId);
item.attachData("folder","temp/user1");
return true;
});
</script>
Posted Mar 16 , edited Mar 16 Kool
michael
I finally figured it out. I added $kulhandle->funcFileHandle= myCustomFileHandle;
and added the function to create the prefix. I didn't realize I also had to run the move_uploaded_file command.
Posted Mar 16 Kool
Anthony Amolochitis
You should just do the renaming on the server side while you move them from the temp folder to the destination folder.
Posted Mar 16 Kool