NetTalk Central

Author Topic: How to get at photos on server in different folder?  (Read 6275 times)

dcpeders

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
How to get at photos on server in different folder?
« on: September 26, 2011, 06:10:37 AM »
I have a win32 app that has the photos stored on the server in a different folder than the main program. I want to build a web app that will access these photos on a browse. The photos are in the folder "c:\rccphoto\ID#\photo#.jpg".

I do not understand how to access these photos from the client machine? I have looked at the example app "Download files", but it does not make any sense to me. Could someone explain what I need to do?

Thank you,

Dave Pederson

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: How to get at photos on server in different folder?
« Reply #1 on: September 26, 2011, 03:33:11 PM »
One of the download examples shows how to serve up files from any where on a machine but also notes that this is very dangerous as it could expose your entire file system.

What I do is copy the files to a sessionID folder under the web\images folder as the browse loads and then delete the folder when the session ends.

dcpeders

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
Re: How to get at photos on server in different folder?
« Reply #2 on: September 26, 2011, 07:28:16 PM »
Thanks for the response Kevin.

Are there any examples showing how this is done in Nettalk? This is my first project using Nettalk and it is slow going trying to figure it out.

Would you use the Serverside code option?

Thanks again,

Dave Pederson

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: How to get at photos on server in different folder?
« Reply #3 on: September 27, 2011, 06:52:04 PM »
You could do this via a variable in your browse which is a Hyperlink to the photo, in the following embed

      ! Start of "Before Table Row"
      ! [Priority 5000]

eg
          Copy('C:\mywndowsapp\' & Clip(AAA:PhotoFileName),'c:\webapp\web\images\' & p_web.SessionID & '\' & Clip(AAA:PhotoFileName))
          L:FileName = 'images/' & p_web.SessionID & '/' & Clip(AAA:PhotoFileName)

I use session variables for my paths and add in validation and code to create the folder etc if it does not exist.

If you're new to Nettalk then spend the time to study all of the examples and embed code. Docs and FAQ are essential reading. I would also invest the money in the book by bruce "Building Web Apps" - it will save you hours upon hours of head scratching. I still refer to it all the time.

Cheers,

Kev



dcpeders

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
Re: How to get at photos on server in different folder?
« Reply #4 on: September 28, 2011, 05:21:44 AM »
Kevin,

Thanks for the code snippet. If I understand correctly, this copy would take place on the server before the browse was sent to the client? This makes sense to me and I will give it a try.

I do have the Nettalk book and I reference it all the time.

Thanks for all your help.

Dave Pederson

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: How to get at photos on server in different folder?
« Reply #5 on: September 28, 2011, 04:26:10 PM »
correct. I did that a long time ago using a hyperlink and thinking about it more, as my files are doc's and not photos (so I don't need them to display in a browse) I would probably copy them on demand and serve up using the serve document example which I use to push out reports. Anyway there are few different ways you could do it.

CyberFerret

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
Re: How to get at photos on server in different folder?
« Reply #6 on: October 01, 2011, 10:31:02 PM »
Guys,

Probably the best way to do this (if you are using Win Vista/Win 7/Win 2003/Win 2008 as the NetTalk server) is to use symbolic links.

We use it on one of our NetTalk projects to link to mass storage on another drive and it work very well.

Basically, if your NetTalk app is in C:\Apps\MyApp and your photos are stored on G:\Data\Photos\WebPhotos and you want the web user to be able to view these photos under the /photos folder on the web server, then you can run the following command:

Code: [Select]
mklink  /d  C:\Apps\MyApp\web\photos  G:\Data\Photos\WebPhotos
You can still create/delete files and folder in G:\Data\Photos\WebPhotos and any changes will be reflected in C:\Apps\MyApp\web\photos - after all, it is just a virtual link to the other folder.

Hope this helps,

Cheers,
Devan


dcpeders

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
Re: How to get at photos on server in different folder?
« Reply #7 on: October 11, 2011, 07:27:02 AM »
OK- I have managed to get my photos to the 'web/photos' folder and that works fine.

Now, where do I process code If the user changes a photo? I want to get the new photo from 'web/photos' and send it back to the server ('c:\myphotos\filename.jpg'), but I can't figure out what embed to use, and if it should be done from the Form or the Browse.

Any help would be appreciated. This group ROCKS.

David Pederson

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: How to get at photos on server in different folder?
« Reply #8 on: October 11, 2011, 07:32:32 AM »
define what you mean by "user changes a photo" please.
Do you mean via a form that has a File Upload field?

cheers
Bruce

dcpeders

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
Re: How to get at photos on server in different folder?
« Reply #9 on: October 11, 2011, 07:36:32 AM »
Yes, I have a form with an upload field.

Dave

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: How to get at photos on server in different folder?
« Reply #10 on: October 11, 2011, 07:49:58 AM »
I'm guessing then the best place would be the
PostInsert
and
PostUpdate
routines in the form.

cheers
Bruce

dcpeders

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
Re: How to get at photos on server in different folder?
« Reply #11 on: October 11, 2011, 08:24:52 AM »
Thanks Bruce, that was what I needed.

Dave