How to edit/manipulate Upload::DB_WEB_PATH

How to edit/manipulate Upload::DB_WEB_PATH

Koen VerhoevenKoen Verhoeven Posts: 13Questions: 6Answers: 0

I'm using the follow code to upload files. This works perfectly:

->upload( Upload::inst( $_SERVER['DOCUMENT_ROOT'].'/documenten/daktuinen/__ID__.__EXTN__' )
                ->db( 'deenk_files', 'file_id', array(
                    'filename'    => Upload::DB_FILE_NAME,
                    'filesize'    => Upload::DB_FILE_SIZE,
                    'web_path'    => Upload::DB_WEB_PATH,
                    'system_path' => Upload::DB_SYSTEM_PATH
                ) )

The current result in the database is: /documenten/daktuinen/2.jpg
I would like to change this to: https://mywebsite.com/documenten/daktuinen/2.jpg

But whatever I try, I can't find out how to influence the value for DB_WEB_PATH. Who knows how to do this?

Thanks for your help!

Answers

  • rf1234rf1234 Posts: 948Questions: 46Answers: 131

    Why would you manipulate DB_WEB_PATH if all you want is to have a different entry in your database? You can do this for example:

    Upload::inst( $_SERVER['DOCUMENT_ROOT'].'/documenten/daktuinen/__ID__.__EXTN__' )
    ->db( 'deenk_files', 'file_id', array(
        'filename'    => Upload::DB_FILE_NAME,
        'filesize'    => Upload::DB_FILE_SIZE,
        'web_path'    => 'https://mywebsite.com' . Upload::DB_WEB_PATH,
        'system_path' => Upload::DB_SYSTEM_PATH
    ) )
    
  • allanallan Posts: 50,737Questions: 1Answers: 7,581 Site admin

    Actually - I'd say just as the domain name prefix when you are outputting it on the client-side:

    return '<img src="https://mywebsite.com/'+editor.file( 'files', file_id ).web_path+'"/>';
    

    Allan

Sign In or Register to comment.