12-23-2009 08:30 AM
Hello experts,
i want to upload one image on server using post method with alongsome parameter like file name,status,tag,deviceid,device name.
server taking some windows credentials also. I am connecting one .html page which in my url it takes all the paramter and in action it goes to .php file and it upload image on server side.
I am using this code, i ma trying from last 3 days but i am not getting success.
Please Help me...
My code is:-
private String httpConn(String file){ HttpConnection conn = null; OutputStream os = null; InputStream is = null; String url = ""; int respcode=0; //web service path where image will be uploaded. url="http://usertest
asstest@demo.possage.com/admin/image_upload_iphone
0){ } }while(len>0);*/ respcode=conn.getResponseCode(); }catch(Exception e){ e.printStackTrace(); }finally{ //System.out.println("Close connection"); try{ os.close(); }catch(Exception e){} try{ is.close(); }catch(Exception e){} try{ conn.close(); }catch(Exception e){} } return Integer.toString(respcode); }
Regards
Pankaj Pareek.
Solved! Go to Solution.
12-23-2009 08:39 AM - edited 12-23-2009 08:39 AM
This looks like a repeat of a previous Thread you were involved in:
Just to make sure we don't cover the same ground, have you written the Serverside processing that will accept the image?
12-24-2009 05:02 AM
Hello,
i am unaware of server side code.I know only taht server using .php code which is calling from .html file.
and this .html i am calling from httpconnection.
12-24-2009 06:40 AM
"i am unaware of server side code"
Then you can't do it, you do not enough information. The people who wrote the Server Side processing must tell you what you should do in your code. Go talk to them. There is no point talking to us until you know what the Server is expecting.
Remember also that this is a BlackBerry forum, so you should not expect answers here to questions like "what are http headers?", and "what does HTTP code nnn really mean?".
12-25-2009 08:51 AM
How to upload image with some paramerers.Server has one webservice which has some credentials and it uploading image and write parameters in log file.I write some code but not getting success
On server side one . html file which is calling in url and this .html file calling one script which is written in .php and this php taking some paramerts and it uploading image.
Server Side code:-
$filename = $_POST['filename'];
$tag = $_POST['tag'];
$status = $_POST['status'];
$deviceid = $_POST['deviceid'];
$devicemodel = $_POST['devicemodel'];
$fp=fopen('./test/log.txt','w');
fwrite($fp,$filename,strlen($filename));
fwrite($fp,$tag ,strlen($tag ));
fwrite($fp,$deviceid ,strlen($deviceid));
fwrite($fp,$devicemodel ,strlen($devicemodel));
fwrite($fp,$status ,strlen($status));
fclose($fp);
$uploaddir = './test/';
$file = basename($_FILES['image']['name']);
$uploadfile = $uploaddir . $file;
if (move_uploaded_file($_FILES['image']['tmp_name'], $uploadfile)) {
echo "http://iphone.zcentric.com/uploads/{$file}";
}
12-26-2009 07:55 AM
I made the comment earlier that you should not expect answers to http questions. Similarly, ability to read and write php is not too useful on a BlackBerry device, so I would next expect much expertise on the BlackBerry Java forum.
I think you need to analyze the php and turn it into a POST request, so figure out the post data that you need to include in the http POST.
Another way to do this would be to get someone to write an html page for you that submitted data to this Server Code. In fact I suspect you already have this, so that would be more useful than this php code.
You will find people on the forum who have written php but I think it would be much more useful for you to understand the process. So you could also look up the php documentation and the html documentation and figure out what is going on at the server end. Perhaps even write some php yourself. Then you could help the next person who comes along with a request like this!
12-28-2009 06:43 AM
This is a solution guys:-
see it..
http://wiki.forum.nokia.com/index.php/HTTP_Post_mu
12-05-2010 07:58 PM
Just for the benefit of people who stumble on this thread .... I'm using the HttpMultipartRequest class linked to in the previous post. It works fine for very small uploads (< 10KB for me), but does not work for larger uploads, when built into my BlackBerry app. The code in question is just generic J2ME code, and is not necessarily tested to work correctly on BlackBerries, with arbitrary file upload sizes.
If I figure out how to modify this class to work for BlackBerry apps, I'll try to remember to post what I learn here. But, I wanted people to know that they shouldn't expect this "solution" to necessarily solve their problem, without further work.