I'm trying to upload a file via HTTPUTILS.POSTFILE and when I check on the server, the files are uploaded, but I still get Job.Success=False in JobDone sub.
This is the code that's sending the file:
This is the PHP page code:
I have one JobDone sub, and it goes like this:
So, I need to have Job.Success=True in order to continue with the code.
I've had the same code and the same PHP page on another server, and all went fine. Could it be that there are some settings on PHP server that I have to enable in order to get a valid response after file upload?
This is the code that's sending the file:
B4X:
Dim myHttpJob As HttpJob
url = Main.ServerName & "/upload.php?file=" & ImeZipFajla
myHttpJob.Initialize("hc", Null)
myHttpJob.PostFile(url,File.DirDefaultExternal & "/send" ,ImeZipFajla)
This is the PHP page code:
PHP:
<?php
$filename="";
$user="";
$str = file_get_contents('php://input', 'r');
$saved_name="upload/$user/$filename";
$fp=fopen($saved_name,"w");
if(!fwrite($fp,$str))
{echo "Cannot write to file :$saved_name";}
else
{$zip = new ZipArchive;
$res=$zip->open("$saved_name");
if ($res === TRUE)
{$zip->extractTo('upload/'.$user.'/');
$zip->close();}
else
{ echo 'Error: unzip!';}
}
fclose($fp);
#unlink('upload/'.$filename);
?>
I have one JobDone sub, and it goes like this:
B4X:
Sub JobDone (Job As HttpJob)
Dim req As HttpRequest
ProgressDialogHide
Log("Job:" & Job.JobName & " - " & Job.Success)
If Job.Success=True AND Posao="Upload" Then
hc.Initialize("hc")
req.InitializeGet(Main.ServerName & "/upis.php?file=" & ImeFajla)
hc.Execute(req,999)
End If
End sub
So, I need to have Job.Success=True in order to continue with the code.
I've had the same code and the same PHP page on another server, and all went fine. Could it be that there are some settings on PHP server that I have to enable in order to get a valid response after file upload?