HazzardWeb

HazzardWeb supports this item

Supported

This author's response time can be up to 1 business day.

102 comments found.

Hi I have managed to change the folder where uploads are uploaded to, this works fine and creates folders based on session variables.

The code that does this is as follows…..

// Configuration

$config[‘debug’] = true; session_start(); $dirname = ‘files/Lawsons_Survey_’ .$_SESSION[‘job_id’]; $config[‘upload_dir’] = DIR.’/’ .$dirname .’/’; $config[‘image_versions.thumb’] = array( ‘width’ => 120, ‘height’ => 120 );

// Events

/** * Fired before the file upload starts. * * @param \Symfony\Component\HttpFoundation\File\UploadedFile $file */ $handler->on(‘upload.before’, function ($file) { $filename = ”../files/” . $dirname . ”/”; if (!file_exists($filename)) { // The folder does not exist so we need to create it. mkdir(”../files/” . $dirname, 0777); } $original_file_name = $file->getClientOriginalName(); // get the name of the file until the first full stop $arr = explode(”.”, $original_file_name, 2); $original_file_name = $arr0; $file->save = ‘Lawsons_Survey_id_’ .$SESSION[‘job_id’] .’’ .$original_file_name; // throw new \Hazzard\Filepicker\Exception\AbortException(‘Error message!’); });

What I can’t seem to solve is what do I need to change to view the files? The files upload properly but I cannot display them. I need to display the uploaded files from their folders they were uploaded to if that makes sense.

The links created after a successful upload are incorrect they do not seem to use the folders I have created.

Alan

Hi, you have to change the upload_url too with your custom session ( http://docs.hazzardweb.com/filepicker/2.0/configphp#upload_url ).

As for the loaded files, the script will simply look in the upload_dir and list them from there. In your case I see you do something inside the upload event. Can’t really understand what since it’s not formatted.

But all you really have to do is just return the files you want listed, these can be from database: http://docs.hazzardweb.com/filepicker/2.0/howto#fetch-files

Hi thanks for the support and quick reply, however I am still struggling.

I will recap for you.

I am able to upload files to directories created on the fly depending on a session variable using the following code.

// Configuration

$config[‘debug’] = true; session_start(); $dirname = ‘files/Lawsons_Survey_’ .$_SESSION[‘job_id’]; $config[‘upload_dir’] = DIR.’/’ .$dirname .’/’; $config[‘image_versions.thumb’] = array(‘width’ => 120,’height’ => 120);

  • Fired before the file upload starts. *
  • @param \Symfony\Component\HttpFoundation\File\UploadedFile $file */ $handler->on(‘upload.before’, function ($file) { $filename = ”../files/” . $dirname . ”/”; if (!file_exists($filename)) { // The folder does not exist so we need to create it. mkdir(”../files/” . $dirname, 0777); }

$original_file_name = $file->getClientOriginalName(); // get the name of the file until the first full stop $arr = explode(”.”, $original_file_name, 2); $original_file_name = $arr0; $file->save = ‘Lawsons_Survey_id_’ .$SESSION[‘job_id’] .’’ .$original_file_name; // throw new \Hazzard\Filepicker\Exception\AbortException(‘Error message!’); });

The upload works fine and creates new folders based on a session variable i.e. Lawsons_Survey_1, Lawsons_Survey_2, Lawsons_Survey_3 etc. As I said this works OK.

The issue I have is that the code is not listing the files uploaded properly. It is showing them as in the default folder and not those created on upload if that makes sense. I know you have and keep referencing http://docs.hazzardweb.com/filepicker/2.0/howto#fetch-files but I do not understand what I need to put in the http://docs.hazzardweb.com/filepicker/2.0/howto#fetch-files code to show the files that have been uploaded in the directories created.

Alan

Please post your code in a gits on GitHub so I can understand exactly what you’re doing there.

Hi,

I am trying to select only the images uploaded from each user to show only in the profile of each user (not show all te images) the database right now save the rute and the id of the user, but I try with this code to show the user image without success:

$handler->on('files.fetch', function ($file) use ($handler){ $file = $db->table('IMAGES')->select('imageRute')->where('id_User', $id); });

How can I get the right form to show only the images of each user in each profile?

Thank you for your fast respond.

I already tried with that form, but always show me all the images and I don’t know why not only show me the images of the profile user.

Here my js:

$('#filepicker').filePicker({ url: 'upload.php', debug: false, data: function() { return { filename: $('#filename').val(), id_Client: $('#id_Client').val(), images: $('#images').val() } }, ui: { autoUpload: false }, plugins: ['ui', 'drop', 'crop'] }); Here the php $handler->on('files.fetch', function (&$files) use ($handler) { $files = $handler->request()->get('id_Client'); });

Hi, do you know what I am making bad? always show me the entire images in the DB…not only the user image (id_Client)

Could you send the me the link or an FTP account so I can take a look ? Use the private messages or at hazzardweb@gmail.com.

by
by
by
by
by
by