Hello guys!!
I’m trying to get the user to select a photo of the device for their avatar, so far so good.
I used the library to have the user select the desired photo.
timer.performWithDelay( 100,
function() media.selectPhoto( { listener = sessionComplete, mediaSource = PHOTO_FUNCTION, destination = { baseDir=system.TemporaryDirectory, filename=tmp_image_name } } ) end
)
return true
– tmp_image_name corresponds to a random string of type efCvsdS.jpg
So far so good, the user chooses the image and it goes to the temporary directory. Even after the user selects the image, I show it on the screen
local sessionComplete = function(event)
photo = event.target
if event.completed then
toast.show(“picture selected”)
img_temp = display.newImageRect( tmp_image_name, system.TemporaryDirectory, 200, 300)
–local scale = math.max(endWidth / img_temp.width, endHeight / img_temp.height)
–img_temp:scale(scale, scale)
img_temp.x = display.contentCenterX - 170
img_temp.y = display.contentCenterY
else
toast.show(“no picture selected”)
end
end
I checked and the photo is actually in the temporary directory.
Done that, I have a user action that causes me to call my function to move the image from the temporary folder to the documents folder. So I can save this information in the database and be able to use that image later
if img_temp ~= nil then
image_name = getRandomId(8)…".jpg"
local check = copyFile(tmp_image_name, system.TemporaryDirectory, image_name, system.DocumentsDirectory, true )
toast.show( "copy result: " … check )
end
But the problem is precisely in this step of copying the image, I used the function found in the CORONA documentation. And it returns me a fatal error that causes the application to stop. (see error attached)
Please someone could help me to solve this error. I’ve tried everything and I can not
https://pastebin.com/BjszvN0d (the file used in copy image) ** error in line 88
thank you