Limit number of photos

Last post 04-21-2011, 3:47 PM by Eric. 4 replies.
Sort Posts: Previous Next
  •  03-18-2011, 1:45 PM 66745

    Limit number of photos

    Can you limit the number of photos a user can upload?
  •  03-18-2011, 3:48 PM 66747 in reply to 66745

    Re: Limit number of photos

    Dear cyberguy28,
     
    Yes, you can limit the number of photos, you can create custom file handler. Please refer to the following snippet:

    Custom file upload handler

    If you need further control over the parsing of the file uploading request, you can write a custom file upload handler. In handler page (UploadUrl) developers can rename the uploaded files, process other logics programmatically.

    1. <?php require_once "phpuploader/include_phpuploader.php" ?>   
    2. <html>   
    3. <body>   
    4.        <?php   
    5.             $uploader=new PhpUploader();   
    6.             $uploader->Name="myuploader";   
    7.             //Create a new file upload handler   
    8.             $uploader->UploadUrl="myhandler.php";   
    9.             $uploader->Render();   
    10.         ?>                  
    11. </body>   
    12. </html>  
    The following code shows you how to rename the uploaded files, process other logics programmatically in handler page (UploadUrl).
    You can put the validation of photo number in the following file:

     

    1. <?php require_once "phpuploader/include_phpuploader.php" ?>   
    2. <?php   
    3.     $uploader=new PhpUploader();   
    4.   
    5.     $mvcfile=$uploader->GetValidatingFile();   
    6.   
    7.     if($mvcfile->FileName=="accord.bmp")   
    8.     {   
    9.      $uploader->WriteValidationError("My custom error : Invalid file name. ");   
    10.          exit(200);   
    11.     }   
    12.   
    13.     //USER CODE:   
    14.   
    15.     $targetfilepath"savefiles/myprefix_" . $mvcfile->FileName;   
    16.     ifis_file ($targetfilepath) )   
    17.      unlink($targetfilepath);   
    18.     $mvcfile->MoveTo( $targetfilepath );   
    19.   
    20.     $uploader->WriteValidationOK();   
    21.   
    22. ?>  
     
    Thank you for asking
  •  04-21-2011, 3:03 AM 67273 in reply to 66747

    Re: Limit number of photos

    This is from the server side...
    but is it possible by client side ???
     
    As it will be good that user get quick alert, rather than waiting for getting reply from server side.
     
     thank you 
  •  04-21-2011, 8:11 AM 67280 in reply to 66747

    Re: Limit number of photos

    and sorry Eric.. even i can't understand your example of server side also.
    Can u explain me?
    because how handler get the counter of the current image? 
  •  04-21-2011, 3:47 PM 67283 in reply to 67280

    Re: Limit number of photos

    Dear chintanshah,
     
     
     $targetfilepath= "savefiles/myprefix_" . $mvcfile->FileName;
     
    This line means you will save uploaded files to folder "savefiles", you can write code to read folder "savefiles" and check the total file quantity in this folder.
     
    Thank you for asking
     
View as RSS news feed in XML