Hi,
So I am trying to download a jpg image from webpage on a website. I have the link to the photo within my code and it downloads and displays in the simulator but when I push it to test flight to test on my phone, the image does not appear. Here is the code I am using below:
local lunchMenu = nil local function removePhoto() display.remove(lunchMenu) lunchMenu = nil end local function displayphotoFunction() --image removePhoto() lunchMenu = display.newImage("lunch.jpg", system.DocumentsDirectory, display.contentWidth/2, display.contentHeight/2) if (lunchMenu ~= nil) then lunchMenu.width = display.contentHeight - rectangle1.height lunchMenu.height = 1.02\*display.contentWidth lunchMenu.x = lunchMenu.height/2.12 lunchMenu.y = lunchMenu.y + rectangle1.height/2 lunchMenu.rotation = 90 LunchPage:insert(lunchMenu) end end local function networkListener( event ) if ( event.isError ) then print( "Network error: ", event.response ) print( "File not downloaded" ) elseif ( event.phase == "progress" ) then dayTitle.text = "Downloading" elseif ( event.phase == "ended" ) then print( "Download complete" ) timer.performWithDelay(25, displayphotoFunction()) end end local function downloadPhoto() local photoLink = "http://www.packer.edu/uploaded/email\_files/enotify-images/enotify-images-2015-16/menu-we-"..dataLocal.fridayDateString.."-monitor-REV-800.jpg" local params = {} params.progress = "download" params.response = { filename = "lunch.jpg", baseDirectory = system.DocumentsDirectory } network.request( photoLink, "GET", networkListener, params ) print("Attempted to download photo") end local path = system.pathForFile( "lunch.jpg", system.DocumentsDirectory ) local file, errorString = io.open(path, "r") --triggers if photo isnt downloaded if not file then print( "File error: " .. errorString ) downloadPhoto() else displayphotoFunction() end io.close()