Devv Active Member Licensed User Longtime User Oct 17, 2015 #1 i'm using httpUtils to post file to my php script: PHP: <?php $PostData = file_get_contents("php://input"); $File = fopen("test.mp3","wb"); fwrite($File, $PostData); fclose($File); ?> and the b4a code Code: uploader.PostFile(url & "/1.php",File.DirInternal,"test.mp3") every thing is working fine but i cant find a way to upload the file with a specific file name i don't always want the name to be "test.mp3" how can i control the name from b4a ?
i'm using httpUtils to post file to my php script: PHP: <?php $PostData = file_get_contents("php://input"); $File = fopen("test.mp3","wb"); fwrite($File, $PostData); fclose($File); ?> and the b4a code Code: uploader.PostFile(url & "/1.php",File.DirInternal,"test.mp3") every thing is working fine but i cant find a way to upload the file with a specific file name i don't always want the name to be "test.mp3" how can i control the name from b4a ?
DonManfred Expert Licensed User Longtime User Oct 17, 2015 #2 https://www.b4x.com/android/forum/threads/upload-file-with-php.37562/#post-221947 Upvote 0
Devv Active Member Licensed User Longtime User Oct 17, 2015 #3 DonManfred said: https://www.b4x.com/android/forum/threads/upload-file-with-php.37562/#post-221947 Click to expand... i had downloaded your example but it seemed too complex for me could you tell me which one of your 3 example can let me specify the file name, and why is ok http better that httputlis ? Upvote 0
DonManfred said: https://www.b4x.com/android/forum/threads/upload-file-with-php.37562/#post-221947 Click to expand... i had downloaded your example but it seemed too complex for me could you tell me which one of your 3 example can let me specify the file name, and why is ok http better that httputlis ?
DonManfred Expert Licensed User Longtime User Oct 17, 2015 #4 Devv said: could you tell me which one of your 3 example can let me specify the file name, and why is ok http better that httputlis ? Click to expand... okhttp replaces the old httputils. You are forced to do the update if you want to run your apps on Android 6+ Use the okHTTP download (3rd) as b4a part. Use the PHP download (2nd) to see the php part. Upvote 0
Devv said: could you tell me which one of your 3 example can let me specify the file name, and why is ok http better that httputlis ? Click to expand... okhttp replaces the old httputils. You are forced to do the update if you want to run your apps on Android 6+ Use the okHTTP download (3rd) as b4a part. Use the PHP download (2nd) to see the php part.
Devv Active Member Licensed User Longtime User Oct 17, 2015 #5 DonManfred said: okhttp replaces the old httputils. You are forced to do the update if you want to run your apps on Android 6+ Use the okHTTP download (3rd) as b4a part. Use the PHP download (2nd) to see the php part. Click to expand... OK i'm seeing it right now, what is the point from uploading the file as parts ? Upvote 0
DonManfred said: okhttp replaces the old httputils. You are forced to do the update if you want to run your apps on Android 6+ Use the okHTTP download (3rd) as b4a part. Use the PHP download (2nd) to see the php part. Click to expand... OK i'm seeing it right now, what is the point from uploading the file as parts ?
DonManfred Expert Licensed User Longtime User Oct 17, 2015 #6 I dont understand the question!? Upvote 0
Devv Active Member Licensed User Longtime User Oct 17, 2015 #7 DonManfred said: I dont understand the question!? Click to expand... your method will upload the file part by part right ? my question is why we should upload the file as parts why not send it as one part ? my files are small (<1mb) why should we make it parts then send it to the PHP < won't this make the upload slower ? Upvote 0
DonManfred said: I dont understand the question!? Click to expand... your method will upload the file part by part right ? my question is why we should upload the file as parts why not send it as one part ? my files are small (<1mb) why should we make it parts then send it to the PHP < won't this make the upload slower ?
DonManfred Expert Licensed User Longtime User Oct 17, 2015 #8 Devv said: your method will upload the file part by part right ? Click to expand... It will use the right way to send multiple files to a php script. It´s like sending a form with multiple data... The point is that you need to use the correct way to "read" the file from the the given post vars (using the $_FILES array) Upvote 0
Devv said: your method will upload the file part by part right ? Click to expand... It will use the right way to send multiple files to a php script. It´s like sending a form with multiple data... The point is that you need to use the correct way to "read" the file from the the given post vars (using the $_FILES array)
Devv Active Member Licensed User Longtime User Oct 19, 2015 #9 DonManfred said: It will use the right way to send multiple files to a php script. It´s like sending a form with multiple data... The point is that you need to use the correct way to "read" the file from the the given post vars (using the $_FILES array) Click to expand... DonManfred thanks a lot for your help , the soulution i folowed was passing a variable to php using the link ex: mysite.com/test.php?name=1.mp3 Upvote 0
DonManfred said: It will use the right way to send multiple files to a php script. It´s like sending a form with multiple data... The point is that you need to use the correct way to "read" the file from the the given post vars (using the $_FILES array) Click to expand... DonManfred thanks a lot for your help , the soulution i folowed was passing a variable to php using the link ex: mysite.com/test.php?name=1.mp3
DonManfred Expert Licensed User Longtime User Oct 19, 2015 #10 Devv said: the soulution i folowed was passing a variable to php using the link ex: mysite.com/test.php?name=1.mp3 Click to expand... But with this you CAN NOT send any filedata to the server. It will work if you use the multipartupload though. And additional with the multipart you are not limited to the maximum length of an url. So, please ignore my tips and code what you want to. I´m out! Upvote 0
Devv said: the soulution i folowed was passing a variable to php using the link ex: mysite.com/test.php?name=1.mp3 Click to expand... But with this you CAN NOT send any filedata to the server. It will work if you use the multipartupload though. And additional with the multipart you are not limited to the maximum length of an url. So, please ignore my tips and code what you want to. I´m out!
Devv Active Member Licensed User Longtime User Oct 24, 2015 #11 DonManfred said: But with this you CAN NOT send any filedata to the server. It will work if you use the multipartupload though. And additional with the multipart you are not limited to the maximum length of an url. So, please ignore my tips and code what you want to. I´m out! Click to expand... Strange , the method i posted worked for me perfectly i was able to upload any type of file with as much parameters i want. anyway thanks for your help Upvote 0
DonManfred said: But with this you CAN NOT send any filedata to the server. It will work if you use the multipartupload though. And additional with the multipart you are not limited to the maximum length of an url. So, please ignore my tips and code what you want to. I´m out! Click to expand... Strange , the method i posted worked for me perfectly i was able to upload any type of file with as much parameters i want. anyway thanks for your help
DonManfred Expert Licensed User Longtime User Oct 24, 2015 #12 Devv said: Strange , the method i posted worked for me perfectly i was able to upload any type of file with as much parameters i want. Click to expand... If you use get (anything after the ? in the url) then yes. this will work. As long as the maximum length a url is allowed to have. So, giving just a few values like ints this will work. but try to give 5 texts with a length of 32kb together with the filepayload as get parameters. You will reach the limit of an url Upvote 0
Devv said: Strange , the method i posted worked for me perfectly i was able to upload any type of file with as much parameters i want. Click to expand... If you use get (anything after the ? in the url) then yes. this will work. As long as the maximum length a url is allowed to have. So, giving just a few values like ints this will work. but try to give 5 texts with a length of 32kb together with the filepayload as get parameters. You will reach the limit of an url
Devv Active Member Licensed User Longtime User Oct 24, 2015 #13 DonManfred said: If you use get (anything after the ? in the url) then yes. this will work. As long as the maximum length a url is allowed to have. So, giving just a few values like ints this will work. but try to give 5 texts with a length of 32kb together with the filepayload as get parameters. You will reach the limit of an url Click to expand... good to know, thanks for the info i found in the internet it is about "2,083 characters" which will be more than enough for me anyways you seem to bee a pro with http protocol i'm using https post with username and password as parameters is that secure ? can any hacker or the isp know/ see my use name and password ? ex: mysite.com/test.php?name=1.mp3&usr=mruser&psw=mrpassword Upvote 0
DonManfred said: If you use get (anything after the ? in the url) then yes. this will work. As long as the maximum length a url is allowed to have. So, giving just a few values like ints this will work. but try to give 5 texts with a length of 32kb together with the filepayload as get parameters. You will reach the limit of an url Click to expand... good to know, thanks for the info i found in the internet it is about "2,083 characters" which will be more than enough for me anyways you seem to bee a pro with http protocol i'm using https post with username and password as parameters is that secure ? can any hacker or the isp know/ see my use name and password ? ex: mysite.com/test.php?name=1.mp3&usr=mruser&psw=mrpassword