NetTalk Central

Author Topic: How to Upload to a different folder  (Read 8345 times)

Alberto

  • Hero Member
  • *****
  • Posts: 1849
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
How to Upload to a different folder
« 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
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11194
    • View Profile
Re: How to Upload to a different folder
« Reply #1 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

Alberto

  • Hero Member
  • *****
  • Posts: 1849
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: How to Upload to a different folder
« Reply #2 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
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11194
    • View Profile
Re: How to Upload to a different folder
« Reply #3 on: January 29, 2009, 06:42:07 AM »
WebHandler procedure
ProcessLink method
Before parent call.

Cheers
Bruce

Alberto

  • Hero Member
  • *****
  • Posts: 1849
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: How to Upload to a different folder
« Reply #4 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?
-----------
Regards
Alberto

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: How to Upload to a different folder
« Reply #5 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

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11194
    • View Profile
Re: How to Upload to a different folder
« Reply #6 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

Alberto

  • Hero Member
  • *****
  • Posts: 1849
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: How to Upload to a different folder
« Reply #7 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...
-----------
Regards
Alberto

Alberto

  • Hero Member
  • *****
  • Posts: 1849
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: How to Upload to a different folder
« Reply #8 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??
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11194
    • View Profile
Re: How to Upload to a different folder
« Reply #9 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

Alberto

  • Hero Member
  • *****
  • Posts: 1849
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: How to Upload to a different folder
« Reply #10 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'
-----------
Regards
Alberto

Alberto

  • Hero Member
  • *****
  • Posts: 1849
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: How to Upload to a different folder
« Reply #11 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
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11194
    • View Profile
Re: How to Upload to a different folder
« Reply #12 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

charl99

  • Full Member
  • ***
  • Posts: 185
    • View Profile
    • Email
Re: How to Upload to a different folder
« Reply #13 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

Alberto

  • Hero Member
  • *****
  • Posts: 1849
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: How to Upload to a different folder
« Reply #14 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
-----------
Regards
Alberto