NetTalk Central

Author Topic: Upload image file issues  (Read 5406 times)

CaseyR

  • Sr. Member
  • ****
  • Posts: 448
    • View Profile
    • Email
Upload image file issues
« on: August 19, 2015, 01:37:38 PM »
Hi, Bruce

A couple weeks ago we talked briefly about doing a segment on uploading and displaying image files at an NT user group meeting.  The July 30 group was packed and ran long, and I wasn't able to attend Aug 13 in real time, but I wondered if we could do it for Aug 20.   My issue has the following components:

1) the file name must be unique and related to a unique entity;
2) the image display should refresh after uploading;
3) the user must be able to change the image file.
4)for long term data maintenance,  the image file should be deleted when the parent record is

I can do any of these actions, but I can't do all of them.  I think the problem is centered on not being able to save an uploaded image file if it has the same name as an existing image file.   

Thanks.

CaseyR

  • Sr. Member
  • ****
  • Posts: 448
    • View Profile
    • Email
Re: Upload image file issues
« Reply #1 on: August 20, 2015, 05:26:42 PM »
Hi, Bruce

Thanks for the User Group time on this issue today.   You were right,  the new file is being saved properly in the uploads folder.  BUT since the file has the same name and type,  the old image file is being read from the Windows cache not the disk so to the user it appears the file has not been changed.  It can take a few minutes for the cache to clear and restarting the Web server app doesn't help so I am pretty sure it is in the operating system.   The problem is easy to replicate in the File Upload example.

It looks like there is a parameter that can be passed through OS_CreateFile to bypass the cache for read and write operations for specific files, but if that is not practical at least the problem is a lot smaller than it appeared originally.   Thanks again.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Upload image file issues
« Reply #2 on: August 21, 2015, 12:15:21 AM »
Hi Casey,

>> It looks like there is a parameter that can be passed through OS_CreateFile to bypass the cache for read and write operations for specific files, but if that is not practical at least the problem is a lot smaller than it appeared originally. 

We can ignore the disk cache as a source of the problem - so we don't need to worry about the OS_CreateFile. Rather the image is in either;
a) the server cache or
b) the client (browser) cache.

The first step is to identify which it is. It sounds like the browser (you mentioned restarting the server does not help) but let's be 100% sure of that before we go down that road. Turn off the Server-side cache in the WebServer procedure, Performance tab. Then re-do your test. If the problem remains then we know it's the browser-side cache and I can suggest some strategies around that.

cheers
Bruce

CaseyR

  • Sr. Member
  • ****
  • Posts: 448
    • View Profile
    • Email
Re: Upload image file issues
« Reply #3 on: August 23, 2015, 08:25:48 PM »
Turning off Enable File Cache didn't change the problem,  although the first time I tried the image display was updated when I saved the parent record.   The next few times, it drew on a cached image,  even if I closed and restarted the server app.  So if the cache is not in the OS, and not is the server app,  it must be in the browsers (Firefox 40.0.2 and Chrome 44.0.2403.157 both demonstrate the problem)

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Upload image file issues
« Reply #4 on: August 23, 2015, 10:51:53 PM »
Ok, excellent.
It's pretty easy to bypass the browser cache. You want to just add a parameter (any parameter) to the image URL. ie

Image URL : clip(whatever) & '?c=1'

that should do the trick.

cheers
Bruce

CaseyR

  • Sr. Member
  • ****
  • Posts: 448
    • View Profile
    • Email
Re: Upload image file issues
« Reply #5 on: August 24, 2015, 05:13:23 PM »
OK.  But the CreateImage method converts '?c=1' to '%3Fc%3D1' which shows as an error in Firebug.   Editing the html back to  ?c=1 in Firebug does display the right image though, so we are getting close.   Thanks.   

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Upload image file issues
« Reply #6 on: August 24, 2015, 10:42:27 PM »
I have tweaked 8.60 so it should cope with that.

cheers
Bruce

CaseyR

  • Sr. Member
  • ****
  • Posts: 448
    • View Profile
    • Email
Re: Upload image file issues
« Reply #7 on: August 25, 2015, 08:28:44 AM »
Excellent.  Thanks so much.