jQuery-File-Upload icon indicating copy to clipboard operation
jQuery-File-Upload copied to clipboard

Don't show all uploaded files

Open tijmenamsing opened this issue 14 years ago • 14 comments

Hello,

I'd like to know what I need to do in order to display only the files that are uploaded in the current session. What I mean is that I don't want to display all files that are in the /jqueryupload/server/php/files folder, but only the files that the user just uploaded.

tijmenamsing avatar Mar 22 '12 20:03 tijmenamsing

I am trying to figure out the same thing... any ideas, anyone?

DynamicProgramr avatar Mar 28 '12 08:03 DynamicProgramr

Is it possible to save data about uploaded files in cookies ( and don't show all uploaded files ) ??

michalgce avatar Mar 28 '12 10:03 michalgce

add index.php

             <p>
             <a href="index.php">index.php</a><br>
                    <a href="index.php?album=files">index.php?album=files</a><br>
                    <a href="index.php?album=other">index.php?album=other</a><br>
            </p>

            <?php
            if (isset($_GET['album']) AND ($_GET['album'] != NULL) ) {
              $this_album = $_GET['album'];                 
              $_SESSION['album'] = $this_album;     
                // Create a new folder/album  ./index.php    ./server/php       
                // secure login function here!!!! 
        // change ./server/php/ on  ./server/php/user_identification  or other place/database
            $folder_album = "./server/php/" . $this_album . "/";
            $folder_thumb = $folder_album . "/" . "thumbnails";
                        if (!file_exists($folder_album)) { //if a folder not exists
                        mkdir($folder_album); //create
                        mkdir($folder_thumb); //create thumbnails
                // end create                           
            // view of content template-upload, template-download
            } else {
            $_SESSION['album'] = ""; 
             unset($_SESSION['album']);                 
            // does not display content
            // 
            }
            ?>              

Remember to create secure catalogs!

upload.class.php add function __construct(

            if (isset($_SESSION['album']) && ($_SESSION['album'] != NULL)) {
            $place = $_SESSION['album'];
            }

change // $this->options = array(

            'upload_dir' => dirname($_SERVER['SCRIPT_FILENAME']).'/'.$place.'/',
            'upload_url' => $this->getFullUrl().'/'.$place.'/', 

// 'thumbnail' => array(

            'upload_dir' => dirname($_SERVER['SCRIPT_FILENAME']).'/'.$place.'/thumbnails/',
            'upload_url' => $this->getFullUrl().'/'.$place.'/thumbnails/',      

fonder avatar Mar 30 '12 17:03 fonder

Try to uncomment following in upload.class.php

protected function get_file_objects() { return array_values(array_filter(array_map( array($this, 'get_file_object'), scandir($this->options['upload_dir']) ))); }

alexkappel avatar Apr 23 '12 21:04 alexkappel

thanks alexkappel, that seems to do exactly what I want!

tijmenamsing avatar Apr 23 '12 21:04 tijmenamsing

+1 to alexkappel , however for me it was "comment" (not uncomment) that did the trick! =)

bluimp is amazing! And the more I bump into issues, the more I like it, cause I discover how relatively easy it is to find answers! :)

ghost avatar Aug 06 '12 21:08 ghost

do not get any answer from ur side

singh-sta avatar Dec 04 '12 12:12 singh-sta

Hello, where is the file upload.class.php?

Casper-X avatar Dec 13 '12 08:12 Casper-X

In cakephp plugin it's at app/Plugin/FileUpload/Controller/Component/UploadComponent.php

cbilgili avatar Jan 10 '13 11:01 cbilgili

Any ideas for those of us not using cake?

aweeden avatar Mar 14 '13 02:03 aweeden

Where to add this and How?? Anyone help?? New to programming..Can anyone add this above code and send attachment. Please. Jizza why don't you do that??

gkm027 avatar May 20 '13 15:05 gkm027

In server/php/UploadHandler.php, comment out this entire function by putting // in front of every line:

    protected function get_file_objects($iteration_method = 'get_file_object') {
        $upload_dir = $this->get_upload_path();
        if (!is_dir($upload_dir)) {
            return array();
        }
        return array_values(array_filter(array_map(
            array($this, $iteration_method),
            scandir($upload_dir)
        )));
    }

It becomes:

//    protected function get_file_objects($iteration_method = 'get_file_object') {
//        $upload_dir = $this->get_upload_path();
//        if (!is_dir($upload_dir)) {
//            return array();
//        }
//        return array_values(array_filter(array_map(
//            array($this, $iteration_method),
//            scandir($upload_dir)
//        )));
//    }

This stops php from looking for the files when a user refreshes, and clearing the table.

vgaparadise avatar Aug 30 '13 01:08 vgaparadise

When I commented the lines as shown above, my form would fail upon submit. I also had to comment out the lines at about line 895: //$response = array( //$this->options['param_name'] => $this->get_file_objects() //); Which makes sense because it calls the function that was just commented. Just thought I'd leave this in case it helps.

michaeljberry avatar Oct 10 '13 07:10 michaeljberry

I have used above code. It works what i expects but it will display error when i click startupload button.

ERROR:SyntaxError: JSON.parse: unexpected character. Please help me to resolve this error

srajas0 avatar Nov 07 '13 05:11 srajas0