How to edit/manipulate Upload::DB_WEB_PATH

How to edit/manipulate Upload::DB_WEB_PATH

Koen VerhoevenKoen Verhoeven Posts: 25Questions: 7Answers: 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!

This question has accepted answers - jump to:

Answers

  • rf1234rf1234 Posts: 2,801Questions: 85Answers: 406
    Answer ✓

    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: 61,446Questions: 1Answers: 10,054 Site admin
    Answer ✓

    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

  • Koen VerhoevenKoen Verhoeven Posts: 25Questions: 7Answers: 0

    I'm really sorry for my half-year later reply. Both answers are perfect. I was looking in the wrong direction.

This discussion has been closed.