tsneterr: (3) URL using bad/illegal format or missing URL
matthias_livecode_150811 at m-r-d.de
matthias_livecode_150811 at m-r-d.de
Sun Dec 17 06:45:00 EST 2023
Hello Klaus.
please see the example below. In my example i am posting a zip file with images to a livecode server script
Livecode script
on mouseup
answer file "Select zip file..."
if it is empty then exit to top
put "<file>" & it into tArchive
if libUrlMultiPartFormData(tForm,"Archive", tArchive) is not empty then
altlog the long system time & " - error:" & it
else
set the httpHeaders to line 1 of tForm
altlog the long system time & " - Upload gestartet"
post line 2 to -1 of tForm to url "https://MYSERVER.COM/upload_bilder.lc"
put it into postResult
set the httpHeaders to empty
switch postResult
case postResult begins with "Bildupload fehlgeschlagen" is true
## your script for upload error
break
case postResult begins with "Bildupload okay" is true
## your script for successful upload
break
end switch
end if
end mouseup
Livecode Server script
<?lc
set the errorMode to "inline"
-- check for errors
if $_Files["Archive"][error] is not empty
then
-- this output will be used as return value by the mouseup script
put "Upload-Fehler"
put the long system time && "- Upload-Fehler - " & $_files["Archive"][error] &return after URL "file:uploaderror.txt"
else
put $_Files["Archive"][name] into tFileName
-- check if the correct file was uploaded
-- in our case we always upload a file with same name
if tFileName= "bilder_ohne_logo.zip"
then
-- this output will be used as return value by the mouseup script
put "Bildupload okay"
-- here comes the script for processing the uploaded file....
-- e.g.
put URL ("binfile:"&tFilename) into URL ("binfile:/home/xxxxxx/public_html/bilder_ohne_logo.zip")
exit to top
end if
?>
I hope there is no error in my example. I simplified my original code for the above example.
In my original version the complete upload and the processing of the uploaded file is automatic w/o user interaction.
The desktop app creates a zip file and posts that zip file to a Livecode Server script which just handles the upload and then returns a success or failure.
According to the upload script my standalone then calls another script on the server for further processing.
Regards,
Matthias
> Am 17.12.2023 um 10:18 schrieb Klaus major-k via use-livecode <use-livecode at lists.runrev.com>:
>
> Hi Matthias,
>
>> Am 16.12.2023 um 23:29 schrieb matthias rebbe via use-livecode <use-livecode at lists.runrev.com>:
>>
>> Hello Klaus,
>>
>> You could try to post the data as a file to the server. There is an array $_files in Livecode server available, which handles the file uploads.
>
> ah, sounds promising, thank you! :-)
> I wanted to post the list directly from an LC field, but can surely store its content to a temp file.
>
> But how is the syntax in my case?
> ...
> put clean_name(tSetlist) into tDateiname
> ## = filename on server
>
> ## put "whatever" & CR & urlencode(fld "setlist") into tInhalt
> put "https://www.MYSERVER.de/setlists.lc?name=" & tDateiname & "&setlist=" & url("file:" & path to file") into tURL #?
> ## Nothing in the dictionary about this
> ...
>
>> Regards,
>> Matthias
>
> Best
>
> Klaus
>
> --
> Klaus Major
> https://www.major-k.de
> https://www.major-k.de/bass
> klaus at major-k.de
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list