NetTalk Central

NetTalk Web Server => Web Server - Ask For Help => Topic started by: John Fligg on February 20, 2012, 03:04:49 AM

Title: Example 26 file upload path problem
Post by: John Fligg 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
Title: Re: Example 26 file upload path problem
Post by: kevin plummer 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.
Title: Re: Example 26 file upload path problem
Post by: John Fligg 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
Title: Re: Example 26 file upload path problem
Post by: Bruce 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
Title: Re: Example 26 file upload path problem
Post by: John Fligg 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
Title: Re: Example 26 file upload path problem
Post by: Bruce 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

Title: Re: Example 26 file upload path problem
Post by: John Fligg 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
Title: Re: Example 26 file upload path problem
Post by: John Fligg 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
Title: Re: Example 26 file upload path problem
Post by: bruce2 on February 20, 2012, 07:30:48 PM
Does not apply to data, only -files- that will be served.