tiny_DnDUp icon indicating copy to clipboard operation
tiny_DnDUp copied to clipboard

Almost perfect

Open bigalgeorge opened this issue 9 years ago • 11 comments

Hi this is brilliant. I wished my coding was as good. Only things I would like to add but after looking at the code, cant is Onclick event on drop receiver instantiate file explorer to manually add multiple files. When form is started eg index.php on open, show preview of current upload directory with preferably a delete method for files which also remains on new uploads.

bigalgeorge avatar Jul 20 '16 00:07 bigalgeorge

I have modify the input file line 89 and add option «multiple». I think you can place this input in the Drop zone (use CSS).

I don't understand your point with «a delete method». You want to clear the list off «Files uploaded» or you want to delete file on the server ?

Oros42 avatar Jul 20 '16 10:07 Oros42

Hi there. I have spent 2 days searching for a good, easy method to implement file uploads. The best are fine-uploader, dropzone, auto-dropzone (PHP) by Bronco, and yours.

Just a few changes on yours would make it more useable than all for PHP programmers auto-dropzone, as the first 2 which are most popular do not work so reliably. Yours you just plug it in and it works.

I thank you for a great job already.

1..Delete button(or delete url) below preview. If preview_lib enabled below enabled preview expands to show all files within uploads with delete url below. Delete action removes files from uploads. 2..array of settings (for external passing) eg preview_px_size,filetype,file_max_size,file_max_num,preview_lib,upload_folders,dz_text 3..Onclick event on dropzone to bring up file explorer for picking files.

bigalgeorge avatar Jul 20 '16 23:07 bigalgeorge

Oh thanks you :-)

I can't tell you when I will finish but I try to do it this week.

Oros42 avatar Jul 21 '16 07:07 Oros42

Hi there I spent today with yours and I notice that you mix PHP with script. Its been acting a bit weird and seems to be something to do with variable line 140 for (var i = 0; i < files.length; i++) { in this function it switches to Sometimes I get pictures loading, then sometimes not; its like var i is losing its reference. Sorry I cant debug script, only PHP.

bigalgeorge avatar Jul 21 '16 07:07 bigalgeorge

Line 141 to 145, the PHP code is here to set the post_max_size value in Javascript. PHP is use by the server to create HTML/Javascript code. And this last code is use by your browser to show you the page. So this code

for (var i = 0; i < files.length; i++) {
    if(files[i]['size'] > <?php 
        $val = trim(ini_get('post_max_size'));
        $last = strtolower($val[strlen($val)-1]);
        switch($last) { case 'g': $val *= 1024; case 'm': $val *= 1024; case 'k': $val *= 1024; }
        echo $val; ?>){
        alert('File "'+files[i]['name']+'" is too big ! (><?php echo trim(ini_get('post_max_size')); ?>)');
    }else{
        size_to_up+=files[i]['size']
        if(size_to_up > <?php echo $val; ?>){
            send(tests, formData);
            var formData = tests.formdata ? new FormData() : null;
            size_to_up=0;                           
        }
        if (tests.formdata) {
            formData.append('file'+i, files[i]);
        }
        preview(files[i]);
    }
}

become this code when it sent to your browser (if post_max_size = 8Mo) :

for (var i = 0; i < files.length; i++) {
    if(files[i]['size'] >8388608){
        alert('File "'+files[i]['name']+'" is too big ! (>8M)');
    }else{
        size_to_up+=files[i]['size']
        if(size_to_up > 8388608){
            send(tests, formData);
            var formData = tests.formdata ? new FormData() : null;
            size_to_up=0;                           
        }
        if (tests.formdata) {
            formData.append('file'+i, files[i]);
        }
        preview(files[i]);
    }
}

For debug Javascript, use the developer tool of your browser. For Firefox : Crtl+shift+i I don't think that var i losing its reference. You should check if files are not too big.

Oros42 avatar Jul 21 '16 08:07 Oros42

Thanks for that I am now using debugger. Very odd around line 137 the statement: else { dropZone.insertAdjacentHTML('afterBegin', '<p class="file" id="f_'+file.name.replace(".","")+'">' + file.name+'

');

Even if true: if (tests.filereader === true && imgType[file.type] === true) { the else seems to be executed or would this be a bug in my trace?

bigalgeorge avatar Jul 22 '16 22:07 bigalgeorge

Ooh if the file you upload is not a png or jpeg or gif then imgType[file.type] === false.

Oros42 avatar Jul 23 '16 14:07 Oros42

I have update my code. Tell me what you think about it.

Oros42 avatar Jul 24 '16 16:07 Oros42

Its clever the way you have made the new config.php I have not seen this method before. Ive made a few small changes to your code; use Meld or similar to compare to your original. It would be useful to have a delete url below each preview file to remove unwanted uploads.

Problem: Can't create config.php :-/ ..........changed to make clearer when permissions issue. Fixed my problem with incoming file uppercase on extension causing no file drop. index.php.zip

I'd like to use this in Webid? [http://www.webidsupport.com]

Do you mind if I do this the project is community open source. It would be great if you could join and help because there is lack of good programmers like you. I could donate for your work up to $US40 sorry not much but better than nothing. There are some things that need doing in Webid that others do not seem interested in working on but they are important issues like their editor is ckeditor which is unreliable and needs to be replaced by another drop-in editor.

If you like, I put your TinyDnUp on one of my website here as a blog. [http://elcheapohost.com/tiny-drag-drop-upload/]

bigalgeorge avatar Jul 24 '16 23:07 bigalgeorge

Thanks you :-) I have update my code. If you have ideas of how to show delete button for unwanted uploads, you can :

  • do it ^_^
  • or send me a picture of what you have in mind

The source code is under Licence Public Domaine. So you can add it to Webid ;-) But I recommend you to wait few days, the time to be sure that tiny_DnDUp is finish.

I can't join your team. I have got too much work and 24h in a day is not enough for me :-s But if you have questions on the integration in Webid, send me a mail at oros [at] ecirtam.net

Thanks for the article on your blog ;-)

Oros42 avatar Jul 25 '16 19:07 Oros42

On 26/07/16 07:53, Oros42 wrote:

Thanks you :-) I have update my code. If you have ideas of how to show delete button for unwanted uploads, you can :

Hi there I dont know your name. Thanks for everything and hope all goes well. I might ask for your help or if I make changes to tinyupdn will advise also. Kindest regards, Alistair.

bigalgeorge avatar Jul 26 '16 19:07 bigalgeorge