loading an image from system.DocumentsDirectory

I’ve been successful in downloading an image to the system.DocumentsDirectory and even loading it using 

[lua]

myImage = display.newImage( event.response.filename, event.response.baseDirectory, 60, 40 )

[/lua]

Now that the file is in the DocumentsDirectory, I cannot seen to find a way to access it again using system.pathForFile

Example. There’s now a image file named “180000.png” in the DocumentsDirectory. This is my code to try to load the image.

[lua]

local attendeeImagePath = system.pathForFile( “180000.png”, system.DocumentsDirectory )

local attendeePicture = display.newImageRect( attendeeImagePath,  410, 410)

[/lua]

I’ve also tried this and other variations:

[lua]

local attendeePicture = display.newImageRect( “/DocumentsDirectory/180000.png”, 410, 410)

[lua]

Any help would greatly be appreciated.

Thanks

The display.newImageRect() API allows you to specify the directory where the files are:

display.newImageRect( [parent,] filename, [baseDir,] width, height )

For example:

local attendeePicture = display.newImageRect( "180000.png", system.DocumentsDirectory, 410, 410)

Rob

Thanks Rob! You are a Miracle! Thanks for all your work on these forums. You’ve saved me time and time again.

And for other people, yes this worked. 

The display.newImageRect() API allows you to specify the directory where the files are:

display.newImageRect( [parent,] filename, [baseDir,] width, height )

For example:

local attendeePicture = display.newImageRect( "180000.png", system.DocumentsDirectory, 410, 410)

Rob

Thanks Rob! You are a Miracle! Thanks for all your work on these forums. You’ve saved me time and time again.

And for other people, yes this worked.