문제

I was wondering, is there a way to block files without extension BEFORE uploading on filepicker ?

Thank you.

Vincent.

도움이 되었습니까?

해결책

There is a way to whitelist the files with the data-fp-mimetype parameter. There is no way to black list. Meaning you can set which files you will except, but not which ones you won't.

다른 팁

I just started using FilePicker today, but I was able to discover the following that's outside any documentation I could find on their site. The javascript they provided pulled the urls of the uploaded files from the variables returned. Within those variables are also the filenames.

Here's the input with the javascript...

<input onchange="out='';fn='';
                for(var i=0;i<event.fpfiles.length;i++)
                  {
                  out+=event.fpfiles[i].url;
                  out+=' '
                  fn+=event.fpfiles[i].filename;
                  fn+=' '
                  };    
              document.getElementById('drop_filename_'+drop_count).value=fn;
              fn='File #'+drop_count+': '+fn+'<br>';            
              document.getElementById('drop_'+drop_count).value=out;
              document.getElementById('dropped_display_'+drop_count).innerHTML=fn;
              document.getElementById('dropped_display_'+drop_count).style.display='';
              drop_count++;
              if(drop_count>5){drop_count=5;}" 
        type="filepicker-dragdrop" 
        data-fp-multiple="true" 
        data-fp-apikey="your_api_key" 
        data-fp-mimetypes="*/*" 
        data-fp-container="modal" 
        data-fp-maxsize="4000000" 
        data-fp-services="COMPUTER">

I added a variable "fn" and filled it with the filename of the file being uploaded. Since it's stored a filepicker.io without an extension, it isn't any threat. However, when submitted to the php script, I can then run through the file and omit any with extensions I deem unwanted.

I had some form fields ready to accept the data provided, which would then send to a php script to be processed.

<span style="display:none;" id="dropped_display_1"></span>
<input type="hidden" name="drop_1" id="drop_1" />
<input type="hidden" name="drop_filename_1" id="drop_fn_1" />
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top