Hi Neo, Try this.. JAVA:
String exsistingFileName = "samplefile.txt"; String lineEnd = "\r\n"; String twoHyphens = "--"; String boundary = "*****"; String urlString="path/db_conn.php"; HttpURLConnection conn; DataOutputStream dos; try{ FileInputStream fileInputStream = openFileInput(exsistingFileName); InputStreamReader isr = new InputStreamReader(fileInputStream ); char[] inputBuffer = new char[fileInputStream .available()]; isr.read(inputBuffer); String readString = new String(inputBuffer); tv.setText("from file"+readString); // ----------> It is reading text from file. 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=\"uploadedfile\";filename=\"" + exsistingFileName +"\"" + lineEnd); dos.writeBytes(lineEnd); // Log.e(Tag,"Headers are written"); // create a buffer of maximum size int maxBufferSize=1024; int bytesAvailable = fileInputStream.available(); int bufferSize = Math.min(bytesAvailable, maxBufferSize); byte[] buffer = new byte[bufferSize]; // read file and write it into form... int 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(Tag,"File is written"); fileInputStream.close(); dos.flush(); dos.close(); }catch(Exception e){tv.setText("this is error"+e.toString()); } PHP: <?php if(count($_FILES)>0){ $target_path = "uploads/"; foreach($_FILES as $file){ $target_path = $target_path . basename($file['name']); if(move_uploaded_file($file['tmp_name'], $target_path)) { chmod($target_path, 0755); echo "The file ". basename($file['name'])." has been uploaded<br />"; } else{ echo "There was an error uploading the file, please try again!<br />"; } } } echo "file name is :".$file['name']."\n"; echo "file completed"; die(); ?> On Thu, May 8, 2008 at 10:00 PM, Dan U. <[EMAIL PROTECTED]> wrote: > > Use a web service between your client and your database. > > On May 8, 6:59 am, neo beyond the matrix > <[EMAIL PROTECTED]> wrote: > > I want to access a mysql database from android –sending/receiving data > > > > great answers welcome :) > > neo > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] Announcing the new M5 SDK! http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---