Hi
Thanks for your quick response.
here is the demo code in which i am downloading image from server. First time when project run it download the image from server and works fine. But second time when it runs file is already exists but not loading through display.newImage.
local function filePathExists(filePath) local exists = false if (filePath) then -- file may exist. won't know until you open it local fileHandle = io.open( filePath, "rb" ) if (fileHandle) then -- nil if no file found exists = true io.close(fileHandle) fileHandle=nil end end return(exists) end local function fileExists(fileName, base) assert(fileName, "fileName is missing") local base = base return filePathExists( system.pathForFile( fileName, base ) ) end local myText = display.newText( "fileExists : ", display.contentWidth\*.5, 400, native.systemFont, 16 ) myText:setFillColor( 1, 0, 0 ) local function downloadFile() local function onDownload(event) if "ended"==event.phase and not event.isError then myText.text = "fileDownloaded : true" local sampleImage = display.newImage("demoImage.png", system.DocumentsDirectory) sampleImage.x = display.contentWidth\*.5 sampleImage.y = display.contentHeight\*.5 elseif "ended"==event.phase and event.isError then myText.text = "fileDownloaded : false" end end local params = {} params.progress = true network.download( "http://placehold.it/120x120&text=image1", "GET", onDownload, params, "demoImage.png", system.DocumentsDirectory ) end if fileExists("demoImage.png", system.DocumentsDirectory) then myText.text = "fileExists : true" local sampleImage = display.newImage("demoImage.png", system.DocumentsDirectory) sampleImage.x = display.contentWidth\*.5 sampleImage.y = display.contentHeight\*.5 else myText.text = "fileExists : false" downloadFile() end
have a look on code.
Note : project works fine on mobile devices but issue is only with html5 case.
Thanks