Hi
I try to upload a file using the HttpJob Post Multipart method.
It works fine with "http" but always fails with "https" (using the same server and php script),
Debugin php errors the array $_FILES has valid data on http but it is always empty using https.
Using an html form to upload files the php script works correctly for both modes.
Thank You for your help.
PHP SCRIPT : upload.php
I try to upload a file using the HttpJob Post Multipart method.
It works fine with "http" but always fails with "https" (using the same server and php script),
Debugin php errors the array $_FILES has valid data on http but it is always empty using https.
Using an html form to upload files the php script works correctly for both modes.
Thank You for your help.
B4X:
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
LogColor("Start Download",Colors.Yellow)
Dim file_local ="testmp.gif" As String
Log(File.Combine(File.DirInternal,file_local))
Log(File.Size(File.DirInternal,file_local))
LogColor("Start Upload",Colors.Yellow)
Dim link="https://mydomain.com/upload.php" As String
Dim j As HttpJob
Dim files As List
files.Initialize
j.Initialize("", Me)
Dim mp As MultipartFileData
mp.Initialize
mp.Dir = File.DirInternal
mp.FileName = file_local
mp.KeyName = "file"
mp.ContentType="multipart/form-data"
files.Add(mp)
j.PostMultipart(link, CreateMap("action":"test"), files)
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Log("data: "&j.GetString)
End If
j.Release
LogColor("End Upload",Colors.Yellow)
End Sub
PHP SCRIPT : upload.php
PHP:
<?php
error_reporting(E_ALL); // Enable Errors
$file_path = "archivos/parasubir/";
echo $_FILES['file']['name'];
$file_path = $file_path . basename( $_FILES['file']['name']);
if(move_uploaded_file($_FILES['file']['tmp_name'], $file_path)) {
echo "success";
} else{
echo "fail";
}
?>
Last edited: