Refresh page after file upload

(7 posts) (2 voices)

Tags:

  1. JamesG, Member

    Hi.
    I found a couple of previous posts with this subject but can't figure out from them how to do it.

    I have a page with a popup to upload an image. this all works fine and the popup gives the confirmation the file has uploaded but when I close the popup I have to manually refresh the main page for it to show the uploaded image.

    Is there a way to refresh the page?

    Main Page
    sp_DBR_View_Order

    select 'dbr.report', 'sp_DBR_Upload_Picture', '[Preview]', 'CUSTID=CUSTID', "event=click|dblclick", 'popup';
    -----------------------

    First upload page

    DROP PROCEDURE IF EXISTS sp_DBR_Upload_Picture
    $$
    CREATE PROCEDURE `sp_DBR_Upload_Picture`(Order_ID int)
    BEGIN

    select 'dbr.upload.options', 'accepted_files', '.gif, .jpg, .jpeg, .HEIC';
    select 'dbr.upload.options', 'add_time', 1;

    select 'dbr.upload', '//var/www/vhosts/73/690027/path_to_image_directory/', 'sp_DBR_upload_file', Order_ID;

    select 'dummy';

    END
    $$

    -------------------
    confirmation page

    DROP PROCEDURE IF EXISTS sp_DBR_upload_file
    $$
    CREATE PROCEDURE `sp_DBR_upload_file`(
    in_path varchar(255),
    in_file varchar(255),
    in_size int,
    Order_ID int,
    inLogin varchar(128)
    )
    begin

    insert into uploads
    values ('',inLogin, in_path, in_file, in_size, Order_ID, now());

    select concat('File ', in_file, ' uploaded ');

    select 'dbr.refresh';

    end
    $$

    --------------------------

    Your help is appreciated.
    Many thanks
    James

  2. myDBR Team, Key Master

    Instead of:

    select concat('File ', in_file, ' uploaded ');
    
    select 'dbr.refresh';

    do:

    select '<script>window.location.reload();</script>';

    The upload report returns just single text element, not a report code.

    --
    myDBR Team

  3. JamesG, Member

    Great, that does just what I want.

    I don't suppose its possible to reduce / compress the image size with the uploader, or set the image quality of jpeg?

    Thanks a million

  4. myDBR Team, Key Master

    I don't suppose its possible to reduce / compress the image size with the uploader, or set the image quality of jpeg?

    For now, no. We can take a look if such options could be added.

    --
    myDBR Team

  5. JamesG, Member

    Would be great. I use the ipad to take photo via the uploader and the files are around 2.5mb :-). Not an urgent thing but would be nice in future

  6. myDBR Team, Key Master

    James,
    The latest myDBR build includes more options for the uploaded images:

    The new options include maxheight, maxwidth and quality.

    You can set the maximum image height to 600 pixels via the option:

    select 'dbr.upload.options', 'maxheight', 600;

    The quality option allows you to set the image compression (0 to 1, the default being 0.8). The image is compressed before it is uploaded, so the reported image size will be the compressed size. The compression is for the JPG and WebP images (WebP compression results will vary between the browser).

    Btw, the accepted_files no longer need the '.'-prefixes, so you can set the option to be 'jpg,png,webp' or the older way '.jpg,.png,.webp'
    --
    myDBR Team

  7. JamesG, Member

    Wow, you are brilliant. Thats great


Reply

You must log in to post.