R Rabbit Member Licensed User Longtime User Jan 16, 2015 #1 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!
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 Jan 16, 2015 #2 https://www.b4x.com/android/forum/threads/upload-file-with-php.37562/#post-221947 Upvote 0
R Rabbit Member Licensed User Longtime User Jan 16, 2015 #4 By the way, Can I use PostFile as below? Code: Dim sendimg As HttpJob sendimg.Initialize("StringJob", Me) sendimg.PostFile("http://www.xxx.com/upload_file.php", File.DirRootExternal & "/test/", "001.jpg") _____ Upvote 0
By the way, Can I use PostFile as below? Code: Dim sendimg As HttpJob sendimg.Initialize("StringJob", Me) sendimg.PostFile("http://www.xxx.com/upload_file.php", File.DirRootExternal & "/test/", "001.jpg") _____
DonManfred Expert Licensed User Longtime User Jan 16, 2015 #5 Yes. But you then can not use php in the way you expect... $_FILES will not be filled. You need to use a multipart-post-request to let php handle it correctly. Upvote 0
Yes. But you then can not use php in the way you expect... $_FILES will not be filled. You need to use a multipart-post-request to let php handle it correctly.