Android Question how to debug Multipart Posting ?

peacemaker

Expert
Licensed User
Longtime User
HI, All

Server with PHP-script and form
B4X:
<html>
<head>
  <title>Uploading</title>
</head>
<body>
      <h2><p><b> File Upload </b></p></h2>
      <form action="img_post.php" method="post" enctype="multipart/form-data">
      <input type="file" name="filename"><br>
      <input type="submit" value="Upload"><br>
      </form>
</body>
</html>

via a Web-browser uploads the photo by a php-script OK, with the response:

B4X:
ok
Array ( [filename] => Array ( [name] => IMG_20160626_221838.jpg [type] => image/jpeg [tmp_name] => /home/pavel/data/mod-tmp/php9tBvlI [error] => 0 [size] => 2759123 ) )

But my app
B4X:
Dim h As HttpJob
h.Initialize("uploadphoto", Me)
Dim fd As MultipartFileData
fd.Initialize
fd.KeyName = "filename"   ' NOT "file" !!!!!!
fd.Dir = Folder
fd.FileName = Fname
fd.ContentType = "image/jpeg"
Dim m As Map
m.Initialize
m.Put("login", Main.Login)
m.Put("order", Orders.CurOrderID)
h.PostMultipart(UploadURL, m, Array(fd))

always gets error for the same photo file, and wrong file size:
B4X:
Error uploading
Array ( [filename] => Array ( [name] => IMG_20160626_221838.jpg [type] => image/jpeg [tmp_name] => /home/pavel/data/mod-tmp/php9tBvlI [error] => 0 [size] => 2759125 ) )

How to debug ?
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
post your php code
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
name="filename" !!!!!!
so must be
fd.KeyName = "filename"
delete the thread, pls
 
Upvote 0
Top