I want to upload an image file from B4A to Sql database. I meet the following error: " Cannot Send files from assets folder" . I have already added the file. Would you give me some advise.
Thanks
Mak
#-------------------------------------------------- PHP File-----------------------------
Thanks
Mak
B4A Code:
Sub Activity_Create(FirstTime As Boolean)
'Activity.LoadLayout("Layout")
Dim job2 As HttpJob
'Send a post request
job2.Initialize("job2",Me)
job2.PostFile("https://www.repairfairyhk.com/UpLoadImage.php",File.DirAssets,"photo1.jpg")
End Sub
Sub JobDone(Job As HttpJob)
Log("JobName =" & Job.JobName & ",Success= " & Job.Success)
If Job.Success = True Then
'Print the result to the logs
Log(Job.GetString)
Else
Log("Error: " & Job.ErrorMessage)
ToastMessageShow("Error: " & Job.ErrorMessage,True)
End If
Job.Release
End Sub
#-------------------------------------------------- PHP File-----------------------------
Php File:
<?php
$allowedExts = array("gif","jpeg","jpg","png","txt");
$extension = end(explode(".", $_FILE["file"]["name"]));
move_uploaded_file($_FILES["file"]["tmp_name"],"upload/". $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $FILES["file"]["name"];
?>