--
Dim linkdb As String
linkdb="http://www.test.net/B4A.php"
Dim su As StringUtils
Dim out1 As OutputStream
out1.InitializeToBytesArray(100) 'size not really important
File.Copy2( File.OpenInput(File.DirRootExternal,"1.jpg"), out1)
job_camera_1.PostString(linkdb, su.EncodeBase64(out1.ToBytesArray))
out1.Close
<?php
$base = file_get_contents("php://input");
$binary=base64_decode($base);
header('Content-Type: bitmap; charset=utf-8');
$file = fopen('images/test_image.jpg', 'wb');
fwrite($file, $binary);
fclose($file);
print json_encode('Image Upload Complete');
?>
include('kernel.php');
i dont know. i dont know this hoster and their possibilities at a webhosting...
Did you have PHP available on it? If yes, did you get any output from the multipartpost.php php-script when calling directly from a browser on your pc?
maybe you can post your app here. Export to zip
Also post the php-script you are using.... i can try it on my webspace then
You have to configure your Php environment : https://my.hostmonster.com/cgi/help/128
And take a look at : https://my.hostmonster.com/cgi/help/110
Code said:<?php
if (!empty($_FILES['uploaded_file']))
{
move_uploaded_file($_FILES['uploaded_file']['tmp_name'],
"../../Control/Upload/".$_FILES['uploaded_file']['name']);
echo "<h2><u>File information</u></h2>";
echo "<b>Name:</b> ", $_FILES['uploaded_file']['name'], "<br />";
echo "<b>Type (MIME):</b> ", $_FILES['uploaded_file']['type'], "<br />";
echo "<b>Size (bytes):</b> ", $_FILES['uploaded_file']['size'], "<br />";
echo "<b>Location:</b> ", $_FILES['uploaded_file']['tmp_name'], "<br />";
echo "<b>Error Code:</b> ", $_FILES['uploaded_file']['error'];
}
else
{
echo "<form enctype='multipart/form-data' action='http://www.FAKESITE.com/php/Upload/index.php' method='post'> <br />";
echo "<input type='hidden' name='MAX_FILE_SIZE' value='' /> <br />";
echo "Choose a file to upload: <input type='file' name='uploaded_file' />";
echo "<input type='submit' value='Upload' /> <br />";
echo "</form>";
}
?>
Code said:Dim filepath As String = IO.Path.Combine(Application.StartupPath, "filename.ext")
Dim url As String = "http://www.FAKESITE.com/php/Upload/index.php"
Dim boundary As String = IO.Path.GetRandomFileName
Dim header As New System.Text.StringBuilder()
header.AppendLine("--" & boundary)
header.Append("Content-Disposition: form-data; name=""uploaded_file"";")
header.AppendFormat("filename=""{0}""", IO.Path.GetFileName(filepath))
header.AppendLine()
header.AppendLine("Content-Type: application/octet-stream")
header.AppendLine()
Dim headerbytes() As Byte = System.Text.Encoding.UTF8.GetBytes(header.ToString)
Dim endboundarybytes() As Byte = System.Text.Encoding.ASCII.GetBytes(vbNewLine & "--" & boundary & "--" & vbNewLine)
Dim req As Net.HttpWebRequest = Net.HttpWebRequest.Create(url)
req.ContentType = "multipart/form-data; boundary=" & boundary
req.ContentLength = headerbytes.Length + New IO.FileInfo(filepath).Length + endboundarybytes.Length
req.Method = "POST"
Dim s As IO.Stream = req.GetRequestStream
s.Write(headerbytes, 0, headerbytes.Length)
Dim filebytes() As Byte = My.Computer.FileSystem.ReadAllBytes(filepath)
s.Write(filebytes, 0, filebytes.Length)
s.Write(endboundarybytes, 0, endboundarybytes.Length)
s.Close()
<?php
if (!empty($_FILES['uploaded_file']))
{
move_uploaded_file($_FILES['uploaded_file']['tmp_name'],
"../../Control/Upload/".$_FILES['uploaded_file']['name']);
echo "<h2><u>File information</u></h2>";
echo "<b>Name:</b> ", $_FILES['uploaded_file']['name'], "<br />";
echo "<b>Type (MIME):</b> ", $_FILES['uploaded_file']['type'], "<br />";
echo "<b>Size (bytes):</b> ", $_FILES['uploaded_file']['size'], "<br />";
echo "<b>Location:</b> ", $_FILES['uploaded_file']['tmp_name'], "<br />";
echo "<b>Error Code:</b> ", $_FILES['uploaded_file']['error'];
}
?>
Dim files As List
files.Initialize
Dim fd As FileData
fd.Initialize
fd.Dir = File.DirAssets
fd.FileName = "snap1.png"
fd.KeyName = "uploaded_file" ' <--- THIS is what you check in php-file with if (!empty($_FILES['uploaded_file']))
fd.ContentType = "application/octet-stream"
files.Add(fd)
Code said:public void doFileUpload(String test_op){
HttpURLConnection conn = null;
DataOutputStream dos = null;
DataInputStream inStream = null;
String exsistingFileName = test_op;
//String exsistingFileName = "/sdcard/1.jpg";
// Is this the place are you doing something wrong.
String lineEnd = "\r\n";
String twoHyphens = "--";
String boundary = "*****";
int bytesRead, bytesAvailable, bufferSize;
byte[] buffer;
int maxBufferSize = 1*1024*1024;
String responseFromServer = "";
String urlString = "http://www.myweb.net/upload_file.php";
try
{
//------------------ CLIENT REQUEST
Log.e("MediaPlayer","Inside second Method");
FileInputStream fileInputStream = new FileInputStream(new File(exsistingFileName) );
// open a URL connection to the Servlet
URL url = new URL(urlString);
// Open a HTTP connection to the URL
conn = (HttpURLConnection) url.openConnection();
// Allow Inputs
conn.setDoInput(true);
// Allow Outputs
conn.setDoOutput(true);
// Don't use a cached copy.
conn.setUseCaches(false);
// Use a post method.
conn.setRequestMethod("POST");
conn.setRequestProperty("Connection", "Keep-Alive");
conn.setRequestProperty("Content-Type", "multipart/form-data;boundary="+boundary);
dos = new DataOutputStream( conn.getOutputStream() );
dos.writeBytes(twoHyphens + boundary + lineEnd);
dos.writeBytes("Content-Disposition: form-data; name=\"uploaded_file\";filename=\""
+ exsistingFileName + "\"" + lineEnd);
dos.writeBytes(lineEnd);
Log.e("MediaPlayer","Headers are written");
// create a buffer of maximum size
bytesAvailable = fileInputStream.available();
bufferSize = Math.min(bytesAvailable, maxBufferSize);
buffer = new byte[bufferSize];
// read file and write it into form...
bytesRead = fileInputStream.read(buffer, 0, bufferSize);
while (bytesRead > 0){
dos.write(buffer, 0, bufferSize);
bytesAvailable = fileInputStream.available();
bufferSize = Math.min(bytesAvailable, maxBufferSize);
bytesRead = fileInputStream.read(buffer, 0, bufferSize);
}
// send multipart form data necesssary after file data...
dos.writeBytes(lineEnd);
dos.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd);
// close streams
Log.e("MediaPlayer","File is written");
fileInputStream.close();
dos.flush();
dos.close();
}
catch (MalformedURLException ex)
{
Log.e("MediaPlayer", "error: " + ex.getMessage(), ex);
}
catch (IOException ioe)
{
Log.e("MediaPlayer", "error: " + ioe.getMessage(), ioe);
}
//------------------ read the SERVER RESPONSE
try {
inStream = new DataInputStream ( conn.getInputStream() );
String str;
while (( str = inStream.readLine()) != null)
{
Log.e("MediaPlayer","Server Response"+str);
}
inStream.close();
}
catch (IOException ioex){
Log.e("MediaPlayer", "error: " + ioex.getMessage(), ioex);
}
}
f (isset($_REQUEST['note1'])){
$note1=trim($_REQUEST['note1']);
mkdir('naoenviadas/'.$note1);
} else {
$iddapessoa="";
}