NetTalk Central

Author Topic: Example 26 file upload path problem  (Read 4279 times)

John Fligg

  • Sr. Member
  • ****
  • Posts: 361
    • View Profile
    • Ambrit Software
    • Email
Example 26 file upload path problem
« on: February 20, 2012, 03:04:49 AM »
The demo works great until you change the location of the file.

Here is my code in the web handler which I have changed ....

 ! self.site.UploadsPath = clip(self.site.WebFolderPath) & '\alternate'
  self.site.UploadsPath = clip(self.site.AppPath) & '\somewhere' !\images'

and this is what is saved as the filename.

ewhere\PICT0036.JPG

If I use the WebFolderPath all works fine. However I cannot use that in a multi user scenario and need a specific path.

The above is only an example as I would not be using AppPath in reality.

BTW I note by checking the example data that someone has changed the path to "alternate" by uncommenting the code. This works great. I THINK that using anything but the WebFolder is an issue.

Thanks

John
« Last Edit: February 20, 2012, 03:07:55 AM by John Fligg »

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Example 26 file upload path problem
« Reply #1 on: February 20, 2012, 03:40:53 AM »
Makes sense. Just use the clarion copy command after the file uploads and copy it where ever you want.

John Fligg

  • Sr. Member
  • ****
  • Posts: 361
    • View Profile
    • Ambrit Software
    • Email
Re: Example 26 file upload path problem
« Reply #2 on: February 20, 2012, 04:00:50 AM »
Hmm is that really safe? If you use the "common" web/uploads folder, what would happen if you got 2 files the same name?

I will be renaming the files using the record ID as part of that name but there is a chance that 2 users could post the same file in the upload folder at the same time.

The only way to limit that is to use the time in the filename I guess.

Thanks

John

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: Example 26 file upload path problem
« Reply #3 on: February 20, 2012, 06:53:41 AM »
bear in mind you can't turn around and _serve_ the pictures, unless they are inside the web folder somewhere.

Bruce

John Fligg

  • Sr. Member
  • ****
  • Posts: 361
    • View Profile
    • Ambrit Software
    • Email
Re: Example 26 file upload path problem
« Reply #4 on: February 20, 2012, 07:07:30 AM »
Not quite sure what you mean by _serve_ the pictures Bruce but this is a disaster for me (I think).

For multi users, do I now have to create individual user folders within the web folder itself????

Basically imaging is a big (huge) part of my app and every user is goint o have to store a lot fo their own images.

Thanks

John

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: Example 26 file upload path problem
« Reply #5 on: February 20, 2012, 07:29:03 AM »
example 40 shows how to serve files outside the web folder.
But this is a bad idea for security reasons - if you don't understand exactly what you're doing you can create a hole which malicious users can exploit.

>> For multi users, do I now have to create individual user folders within the web folder itself?

up to you. multiple folders, or unique names - both work fine.

>> Basically imaging is a big (huge) part of my app and every user is goint o have to store a lot of their own images.

So, what's your "disaster" - they'll be inside the web folder. they have to be somewhere, so they may as well be there.

cheers
Bruce


John Fligg

  • Sr. Member
  • ****
  • Posts: 361
    • View Profile
    • Ambrit Software
    • Email
Re: Example 26 file upload path problem
« Reply #6 on: February 20, 2012, 07:40:04 AM »
Sorry Bruce - a rather unprofessional response.

When you mentioned this I panicked and thought I could only have one folder. I have now created multiple user folders (as with the DATA) and all is working fine now.

Just that now when I create the user folder I have to do the same in the web folder. Not a problem, just one line of code in our office system.

BTW Any news on that FM3 issue?

Thanks

John

John Fligg

  • Sr. Member
  • ****
  • Posts: 361
    • View Profile
    • Ambrit Software
    • Email
Re: Example 26 file upload path problem
« Reply #7 on: February 20, 2012, 05:43:10 PM »
Bruce when you say "opening up a hole" - does that apply to DATA also???

Should everything go inside the web folder or are we just talking about images and the like?

Thanks

John

bruce2

  • Full Member
  • ***
  • Posts: 108
    • View Profile
    • Email
Re: Example 26 file upload path problem
« Reply #8 on: February 20, 2012, 07:30:48 PM »
Does not apply to data, only -files- that will be served.