multiple file upload validator.........Thanks!!!!!!!!!!!!!!!

Dear all,

My website allow users to upload pdf and pics.

When the user upload pics, I can allow them upload multiple pics,

but the problem is i don’t want them to upload multiple pdfs.

Do you guys have any suggestions about how to achieve that?

Only allow multiple upload when ALL FILES are pictures?

Even your files contain ONE pdf, I want the validator reject them…

Thanks so much!

Best,

jiaming

hi, look at Wiki, search for an entry named: "Nice file upload tool". This tool has everything you need for.

http://www.yiiframew…-yii-framework/

to achieve your business rule, then in the action that receive the files you can filter by mime type, if this is a PDF then allow only one upload from the same session or ipaddress.

some like this:

USING SESSION:




public function actionImageReceptor(){

    $s = new CHttpSession();

    $s->open();

    $pdf = 1 * ($s['counter_pdf']);

    if($pdf > 0){

 		// abort

    }else{


        /* Mime type: application/pdf, application/x-pdf, application/acrobat, applications/vnd.pdf, text/pdf, text/x-pdf  */


        if($mimetype == 'application/pdf')

         	$s['counter_pdf'] = 1;


        // continue to upload

    }

   $s->close();

}



<br class="Apple-interchange-newline">

Thanks for your help…

I just use some "pure php codes" things like array… and I solved the problem…

Do you have any suggestions about how to style Yii’s multiple file upload or how to make a “waiting” page after the user click submit?(without using other extensions)

Since the multiple file upload in Yii is not ajax and I don;t want it to be ajax either… but the user will wait a little bit long after they click submit…I am afraid they will refresh the page.

Best

hi, if you can use jquery then,

in any place you like in your uploader view, put a div,




<style>

     #loading {

        border: 1px solid black;

        padding: 10px;

        border-radius: 10px;

   	background-color: yellow;

   	color: black;

    }

</style>


blabla

<input type='submit'  id='submitbutton' />  

<div id='loading'  style='display: none;'>loading your image, please wait...</div> 

blabla


<script>

   $('#submitbutton').click(function(){

   	$('#loading').show();

   	// and when finish, call or reload your page:  $('#loading').hide();  

   });

</script>



That is a smart way!

Thanks so much.

works like a charm.