Android Question How to use PostFile to upload file?

Rabbit

Member
Licensed User
Longtime User
Hi,

I am using Httputils2 to upload file to my server in php

here is the code for the B4A

_____
Dim sendimg As HttpJob
sendimg.Initialize("StringJob", Me)
sendimg.PostFile("http://www.xxx.com/upload_file.php", File.DirRootExternal & "/test/", "001.jpg")
_____
and here is the php server side:

<?php
$file_path = "uploads/";

$file_path = $file_path . basename( $_FILES['uploaded_file']['name']);
if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $file_path)) {
echo "Okay";
} else{
echo "fail";
}
?>




the problem the $_FILES['uploaded_file']['name'] is EMPTY every time!!

even I did use
sendimg.PostFile("http://www.xxx.com/upload_file.php?filename=001.jpg", File.DirRootExternal & "/test/", "001.jpg")

How I can resolve it?

Thank you!
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Rabbit

Member
Licensed User
Longtime User
By the way,
Can I use PostFile as below?

B4X:
Dim sendimg As HttpJob
sendimg.Initialize("StringJob", Me) 
sendimg.PostFile("http://www.xxx.com/upload_file.php", File.DirRootExternal & "/test/", "001.jpg")
_____
 
Upvote 0
Top