Sparkout
Yes. They do. And, Because I had a jpg already in the documents with the same name, it appeared to have been solved with the callback. But oh no. It actually was still having an error because of the keyword URL before the "https//:yourdomain..." parameter in the libURLDownloadToFile command.
So thank you very much for that. Absolutely, one hundred percent, do not put the keyword URL before the actual url when entering the url paramenter for libURLDownloadToFile command!!!
Emily
As to using "profile" versus "profile.jpg" that is correct either way, but you are correct; the former you would have to set the defaultfolder to use just "profile."
Thanks everyone.
Code: Select all
local sDownloadComplete
on mouseUp
put empty into sDownloadComplete
put "https://thedomain/thefile.jpg" into tUrl
put specialfolderpath("documents") & "/profile.jpg" into tPath
delete file tPath ---the old file
libURLDownloadToFile tUrl, tPath, "downloadComplete" ---the callback is below
wait until sDownloadComplete is not empty with messages
if there is a file tPath then ---the new file
set the filename of img "profileImage" to tPath
else
set the filename of img "profileImage" to specialFolderPath("resources") & "/default.jpg"
end if
end mouseUp
command downloadComplete pUrl,pStatus
put empty into sDownloadComplete
switch
case URLStatus(pUrl) is "downloaded"
put "downloadComplete" into sDownloadComplete
return sDownloadComplete
break
case URLStatus(pUrl) is "error"
put "error" into sDownloadComplete
return sDownloadComplete
break
end switch
end downloadComplete