Don't show all uploaded files
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.
I am trying to figure out the same thing... any ideas, anyone?
Is it possible to save data about uploaded files in cookies ( and don't show all uploaded files ) ??
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/',
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']) ))); }
thanks alexkappel, that seems to do exactly what I want!
+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! :)
do not get any answer from ur side
Hello, where is the file upload.class.php?
In cakephp plugin it's at app/Plugin/FileUpload/Controller/Component/UploadComponent.php
Any ideas for those of us not using cake?
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??
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.
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.
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