Uploading A Pdf Using Volley But Gets Null File On Server Folder
I am uploading a pdf file using volley library in database on hostinger domain and also in folder on same hostinger domain Here it is my xml file
Solution 1:
Try this,
In java:
String encode = Base64.encodeToString(bytes, Base64.DEFAULT);
in php:
$file = $_POST['file']['name'];
//$fname = $_POST['fname']['tmp_name'];
$fname = $_POST['file']['tmp_name'];
$file_path = "uploads/";
$actualpath = "http://harpal-projects.16mb.com/sbbs/$file_path/$file";
$sql = "INSERT INTO files (file,fname) VALUES ('$actualpath','$fname') ";
if(mysqli_query($con,$sql))
{
file_put_contents(base64_decode($file), $file_path);
echo"success";
}
else{
echo"fail";
}
Solution 2:
You cannot put a pdf file in a string. What you can do however is put a pdf file base64 encoded in a string. So do that. The php script expects that. Name your functionconvertFileToBase64String()
.
Post a Comment for "Uploading A Pdf Using Volley But Gets Null File On Server Folder"