iOS Question upload image with php from ipad

tango

Active Member
Licensed User
Longtime User
in ipad , iwanto send a image file with upload_file.php

B4X:
Dim job2 As HttpJob
 job2.Initialize("Job2", Me)
 job2.PostFile("https://korkmazlar.club/basari/upload_file.php",File.DirDocuments,"aimg.jpg")

but there is a problem "fail"

please help
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
"fail" how? Are you using JobDone? Wait For? So Success = False? Show the code where you test for the failure.
 
Upvote 0

tango

Active Member
Licensed User
Longtime User
B4X:
    Dim job_camera_1 As HttpJob
    Dim linkdb As String
    linkdb="https://korkmazlar.club/basari/upload_file.php"
    Dim su As StringUtils
    Dim out1 As OutputStream
    out1.InitializeToBytesArray(100) 'size not really important
    File.Copy2( File.OpenInput(File.DirDocuments,"aimg.jpg"), out1)
    job_camera_1.PostString(linkdb, su.EncodeBase64(out1.ToBytesArray))
    out1.Close
End Sub
Sub JobDone (Job As HttpJob)
    'ToastMessageShow(Job.Success&"-"&Job.GetString&"-"&Job.JobName,True)
    If Job.Success = False Then
        Msgbox(Job.ErrorMessage,"error")
    End If
    Job.Release
End Sub

<?php
$base = file_get_contents("php://input");
$binary=base64_decode($base);
header('Content-Type: bitmap; charset=utf-8');
$file = fopen('resimler/test_image.jpg', 'wb');
fwrite($file, $binary);
fclose($file);
print json_encode('Image Upload Complete');
?>

and gives error
[12-Apr-2018 19:06:16 UTC] PHP Warning: fopen(images/test_image.jpg): failed to open stream: No such file or directory in /home/u7661540/public_html/basari/upload_file.php on line 5
[12-Apr-2018 19:06:16 UTC] PHP Warning: fwrite() expects parameter 1 to be resource, boolean given in /home/u7661540/public_html/basari/upload_file.php on line 6
[12-Apr-2018 19:06:16 UTC] PHP Warning: fclose() expects parameter 1 to be resource, boolean given in /home/u7661540/public_html/basari/upload_file.php on line 7
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…