Adapt output image names into costum prefix with autonumbering.

Last post 04-22-2011, 3:25 AM by Zijkant. 3 replies.
Sort Posts: Previous Next
  •  04-21-2011, 5:02 AM 67274

    Adapt output image names into costum prefix with autonumbering.

    Greetings,
     
    First of all thank you for the wonderfull plugin. Works like a charm.
    But now I want to extend the plugin a bit.
     
    I allready went through the forums and noticed that it is possible to define a costum prefix to output the image names.
    Now i want to do the following.
     
    upload: fotoABC.jpg / test564.jpg / building.jpg
     
    now I want that the files are being saved with the following prefix.
     
    uploaded files: picProj1_1.jpg / picProj1_2.jpg / picProj1_3.jpg.
     
    I already found how to define the prefix: picProj1_
    But now i'm facing problems how to implement an autonumbering.
     
    Is there a costum function to count the images selected and then change the name into the current number.
    I already found that there is a count(); function included but that is client side, and i couldn't parse the counted numbers.
     
    If possible to show me a fix
     
    Kind Regards,
     
    Thibaut
  •  04-21-2011, 8:08 AM 67279 in reply to 67274

    Re: Adapt output image names into costum prefix with autonumbering.

    Yes you can do it!!!
    just check the example for "Custom file upload handler". u'll get the exact example over there.
     
  •  04-21-2011, 3:53 PM 67284 in reply to 67274

    Re: Adapt output image names into costum prefix with autonumbering.

    Dear Zijkant,
     
    There isn't a known function to handle this,
    uploaded files: picProj1_1.jpg / picProj1_2.jpg / picProj1_3.jpg.
    These are file name of uploaded files, picproj1 is the file prefix, you can write code to get the "_n" .  For example, you can read target folder, If you only find one existing file in target folder, you can call next file as picProj1-2.jpg ;
    If you find three existing files in target folder, you can call next file as picProj1-4.jpg.
     
    Thank you for asking
  •  04-22-2011, 3:25 AM 67292 in reply to 67284

    Re: Adapt output image names into costum prefix with autonumbering.

    Thanks for the fast reply.
     
    I fixed it as follow:
     
    in file: include_phpuploader.php
     
     I created an $_SESSION named "tellerPics" who keeps count of the pictures i uploaded.
    I placed the session in the following function
     
    1. function _ValidateFile($filename,$filesize)  
    2.     {  
    3.         $_SESSION['tellerPics'] +=1;  
    4.    
     then in the file: ajaxuploadhandler.php
     
    I included the session into my naming prefix.
     
    1. if$uploader->SaveDirectory )  
    2. {  
    3.     $targetfilepath=  "$wd/picProj" . $_SESSION['projectID'] . "_"$_SESSION['tellerPics'] .".jpg";  

     Hope this will also help some people.
    Notice: When you initialise your $phpuploader->render(); you have to be sure that your session has been reset!
View as RSS news feed in XML