NetTalk Central

Author Topic: Redactor - changing the upload path for images  (Read 2564 times)

Niels Larsen

  • Sr. Member
  • ****
  • Posts: 417
    • View Profile
    • Email
Redactor - changing the upload path for images
« on: June 19, 2019, 03:41:28 AM »
Hi

I have a form with a Redactor text field.
On each inserted record I create a directory in the uploads folder. My challenge is to insert the inserted images into the form subfolder.
I've tried with the option imageUpload: '/ uploads / XXXXX /' but I can't get that to work.
Then I have tried to look at the NetWebServerWorker._SendFile and replace it with my own code, but that gets messy - maybe I could make it work, but I dont understand the DisposeAndReturn Routine.
Anyone that have made something that works?

Regards Niels

rjolda

  • Sr. Member
  • ****
  • Posts: 263
    • View Profile
    • Email
Re: Redactor - changing the upload path for images
« Reply #1 on: June 19, 2019, 04:37:09 AM »
Hi Neils,

I have been uploading a file to a named subdirectory depending on the sending entity ( and their defined upload directory).  The trick is to use the Web handler to set the desired path...

In WebHandler
Rename file routine  - AFTER PARENT
***********************************

p_web.RenameFile PROCEDURE(STRING p_name,STRING p_filename,<String p_path>)

ReturnValue          ANY


  CODE
  ReturnValue = PARENT.RenameFile(p_name,p_filename,p_path)
  MESSAGE('pname ' & p_name)
  if p_name = 'upfilename'  ! uploading schedule file
      locpath = p_web.GSV('tProvRptDir')  ! this is the provider file
   !   message('report dir ' & locpath)
      locpath = clip(locpath) & '\INFILE\'  ! this adds teh Infile path
    !  message('upload path: ' & locpath)
      RETURNVALUE = Parent.RenameFile(p_name,p_filename,locpath)
      RETURN  RETURNVALUE
  END
 
*************************************
This makes sure that the file goes to the correct subdirectory.

SECOND- my subdirectories are already in place.  If you are creating one on the fly, you might go back and make sure that the app can see the newly created subdirectory before trying to write to it.

There are a few things for you to try - hope it gets you pointed in the right direction.
Ron Jolda

Niels Larsen

  • Sr. Member
  • ****
  • Posts: 417
    • View Profile
    • Email
Re: Redactor - changing the upload path for images
« Reply #2 on: July 01, 2019, 10:00:07 PM »
Hi Ron

Fantastic - Thanks

Regards Niels