Change url uploaded file path when load file table

68 views
Skip to first unread message

Raul Escamilla

unread,
Feb 19, 2015, 12:56:18 AM2/19/15
to jquery-f...@googlegroups.com
I have a table with several rows, each with a Gallery button that open a modal popup with file uploader:

The gallery button open this modal popup, the content of the modal is a file uploader (same for all buttons):


This is my code of button:


<button id="editGallery_17" class="editGallery btn btn-mini btn-info pull-right"><i class="icon-picture" ></i> Gallery</button>


This is my code that fire a modal popup and pass the id variable for custom upload file path for each row
 $('.editGallery').click(function(e) {
 
e.preventDefault();
  var res = this.id.split("_");
 
 
$('#fileupload').fileupload({
  url: 'upload/server/php/index.php?id='+res[1],
  });
 
 
page.showUploadDialog();
});


And this is the index.php file that change the file upload path:

class CustomUploadHandler extends UploadHandler {
   
protected function get_user_id() {
        $id
= 0;
        
if(isset($_GET["id"])){
            $id
= $_GET["id"];
        
}
        
return $id;
   
}
}


$upload_handler
= new CustomUploadHandler(array(
   
'user_dirs' => true
));



Whit this, I am archive save files in server/php/files/[Id sended] but I have a problem with render previous uploaded files  when click on each gallery buttons, if I upload images for the first row and next open modal for secondo row, previously images uploaded for the first row is rendered, and if I refresh all page and click on any gallery button, nothing is rendered.


How I can pass the path of images to render when click on any gallery button?

Best

Message has been deleted

Chris K.

unread,
Feb 19, 2015, 4:35:51 AM2/19/15
to jquery-f...@googlegroups.com
Use a cookie to store the [Id sended] and don't use the GET Request in the get_user_id. Replace the GET with a cookie.



if ( !array_key_exists('ID-Sender', $_COOKIE) ) {
$user = 'unknown';
} else {
$user = $_COOKIE['ID-Sender'];
}
return $user;
}

Raul Escamilla

unread,
Feb 20, 2015, 11:36:33 AM2/20/15
to jquery-f...@googlegroups.com
thank you, but this not resolve my problem, what happening if I see the gallery for the first record in another machine: the cookie not exist, and not show the files related with it, another problem is that if I click on another gallery row alwais show all images not only related with clicked row.

Thank you!
Reply all
Reply to author
Forward
0 new messages