NetTalk Central

NetTalk Web Server => Web Server - Ask For Help => Topic started by: Alberto on January 28, 2009, 08:29:04 AM

Title: How to Upload to a different folder
Post by: Alberto on January 28, 2009, 08:29:04 AM
Hi,
When using Upload, all files goes to the upload folder.
How can I change that destination folder at run time ?
Thanks
Alberto
Title: Re: How to Upload to a different folder
Post by: Bruce on January 28, 2009, 11:27:50 PM
For security reasons only the server can specify the folder, not the client.

On the server side it's in a property
p_web.site.UploadsPath

Cheers
Bruce
Title: Re: How to Upload to a different folder
Post by: Alberto on January 29, 2009, 06:00:43 AM
OK, but I cant make it work.
Where should I chage it?
I´m trying with

 p_web.site.UploadsPath = 'web\uploads\'&p_web.GetSessionValue('USU:ID')&'\'&p_web.GetSessionValue('DAT:ID')

In which embed should I put it?

Thanks
Alberto
Title: Re: How to Upload to a different folder
Post by: Bruce on January 29, 2009, 06:42:07 AM
WebHandler procedure
ProcessLink method
Before parent call.

Cheers
Bruce
Title: Re: How to Upload to a different folder
Post by: Alberto on January 29, 2009, 07:11:16 AM
Does not work...

My code:

 if p_web.GetSessionValue('DAT:ID')>0

    Goc:MekeDir = longpath()&'\web\uploads\pac'&p_web.GetSessionValue('DAT:ID')

    SolaceResult# = SolaceCreateDirectoryA(Goc:MekeDir,SECURITY_ATTRIBUTES)

    p_web.site.UploadsPath = 'web\uploads\pac'&p_web.GetSessionValue('DAT:ID')

 end

The dir is created but the file is uploaded to the web\upload folder

What am I doing wrong?
Title: Re: How to Upload to a different folder
Post by: kevin plummer on January 29, 2009, 07:27:54 PM
Have you tried:

     p_web.site.UploadsPath = longpath()&'\web\uploads\pac'&p_web.GetSessionValue('DAT:ID')

or even just (creating this folder yourself)

     p_web.site.UploadsPath = 'uploads\test\'

to narrow down the possible problems


Kevin
Title: Re: How to Upload to a different folder
Post by: Bruce on January 29, 2009, 10:36:39 PM
Have a look at what is in the property before you replace it.

You'll see it's "fully qualified", not relative to the current folder.

It needs to be "fully qualified" - and hence Kevin's suggestion is most likely the right one.

   p_web.site.UploadsPath = longpath()&'\web\uploads\pac'&p_web.GetSessionValue('DAT:ID')

Cheers
Bruce
Title: Re: How to Upload to a different folder
Post by: Alberto on January 30, 2009, 04:08:22 AM
The property before the replace is:

p_web.site.UploadsPath = 'web\uploads'

I make the dir with a complete path like:

    Goc:MekeDir = longpath()&'\web\uploads\pac'&p_web.GetSessionValue('DAT:ID')

Then I add the new subdir to the uploadsPath

p_web.site.UploadsPath = 'web\uploads\pac'&p_web.GetSessionValue('DAT:ID')

And the file still uploads to 'web\uploads'

Will try with the fullpath...
Title: Re: How to Upload to a different folder
Post by: Alberto on January 30, 2009, 04:12:48 AM
With the fullpath it still uploads to web\upload.

There must be somthing wrong with the property o the embed.

Any Idea??
Title: Re: How to Upload to a different folder
Post by: Bruce on January 30, 2009, 06:43:17 AM
put some debugging in so you can see what the property is set to before you change it, and after you change it.

Cheers
Bruce
Title: Re: How to Upload to a different folder
Post by: Alberto on January 30, 2009, 07:02:33 AM
Thats what I did!

The property before the replace is:

p_web.site.UploadsPath = 'web\uploads'

Then I create and add the new subdir to the uploadsPath, now the property value is:

p_web.site.UploadsPath = 'web\uploads\pac'

And the file still uploads to 'web\uploads'
Title: Re: How to Upload to a different folder
Post by: Alberto on February 01, 2009, 04:04:13 AM
I think I found the problem...

The p_web.ProcessLink is called many times during allmost every page you see in the browser.
Every time it is called the p_web.site.UploadsPath is :   web\uploads
I change it to  web\uploads\pac
verified, after the parent call p_web.site.UploadsPath is :   web\uploads\pac
but in the next call to the ProcessLink it is web\uploads again!

I think another method is changing it!

More, when you press "save" to upload the file, the file is uploaded BEFORE the ProcessLink is called.

Please help!
Alberto


If I did not be so clear before...

p_web.ProcessLink PROCEDURE(<string p_action>)
  CODE
 
  !debuging... p_web.site.UploadsPath is :   web\uploads
  p_web.site.UploadsPath = 'web\uploads\pac'
 
  PARENT.ProcessLink(p_action)

  !debuging... p_web.site.UploadsPath is :   web\uploads\pac

But the file is still upload to web\uploads!

PS: what is p_action?

Thanks
Alberto
Title: Re: How to Upload to a different folder
Post by: Bruce on February 01, 2009, 08:00:51 AM
you can read about p_action in the netweb.clw file.
Look for the processLink method, and see what it does with the parameter.

In the same way you can also search netweb.clw to see where uploads folder is being set, and where it is being used. In that way oyu can determine the best embed point to use to set it to what you want just before you use it.

Cheers
Bruce
Title: Re: How to Upload to a different folder
Post by: charl99 on February 03, 2009, 04:57:25 AM
Alberto,

Why not take a different approach, simply upload the file where it goes and then copy it where you want it and then delete the file.

The embed point is Routines -> PostInsert -> Start and the code something like this:

    copy(p_web.gsv('PATH') & '\web\'&clip(fil:name),'\\'&clip(GLOD:Server)&'\eds\c\'&left(format(Image:ImageNo,@n_8))&clip(ExtType))
    remove(p_web.gsv('PATH') & '\web\'&clip(fil:name))

OR

    copy(p_web.gsv('PATH') & '\web\'&clip(fil:name),'WHEREVER YOU WANT TO COPY THE FILE TO')
    remove(p_web.gsv('PATH') & '\web\'&clip(fil:name))

fil:name for some reason is always '\uploads\filename.ext'.  Hope this helps.

Cheers
Charl
Title: Re: How to Upload to a different folder
Post by: Alberto on February 03, 2009, 06:09:38 AM
Good Idea

Same Q of the other post...

What happen when two users uploads the same file (same filenema)?

Regards
Alberto
Title: Re: How to Upload to a different folder
Post by: Robert Iliuta on February 03, 2009, 08:24:56 AM
Hallo Alberto,

I tried 3 weeks ago to do the same thing ...... without success. All files uploads to upload folder. I try to do in different ways but doesn't work.

I think it's something from NT .

Next week I will go again to check this issue because I have user that will upload the same file .... and I need to upload files to different folders.

To copy is not the best method. Why should I write a routine to monitored the upload folder ? Simple will be to upload to different folder.

If someone has an example , please share that example.

Thank you,

Regards,
Robert Iliuta
Title: Re: How to Upload to a different folder
Post by: Alberto on February 13, 2009, 05:28:44 AM
Bruce,

I´ve tried everything...
I´ve looked into the inc, clw and did not found a way to set the p_web.site.UploadsPath
without it beeing reverted magically to the default value!

Please, take a look! its important for some of us...

Thanks
Alberto
Title: Re: How to Upload to a different folder
Post by: Bruce on February 16, 2009, 12:38:31 AM
I have put some (commented out) code in the Example 26 for the next build, which places the file into web\alternate instead of \web\uploads.

Cheers
Bruce