473,788 Members | 2,897 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Upload picture from winmobile (C#) using php

31 New Member
I know this is a commonly asked question, so sorry in advance, but even though it seems to be asked fairly frequently, I can't seem to find good code on it.

Essentially, I just want to upload a file to my website (on site-side using PHP & post) in windows mobile. Can anyone help me out? Sorry for the brevity, if you want details just let me know.
Nov 12 '08 #1
5 2942
RedSon
5,000 Recognized Expert Expert
What have you already tried?
Nov 13 '08 #2
markmcgookin
648 Recognized Expert Contributor
Depending on your setup, a web service might be in order. If this is for Windows Mobile it is incredibly easy to add a web reference to a project that will accept something like a base64 string or byte[] to transfer your file, then your server side web service could read this in then create the file.
Nov 14 '08 #3
Cyprus106
31 New Member
This is what I started, but I couldn't seem to get anything to happen...

EDIT: Bear in mind I've completely winged this. Truthfully I just don't have a clue and this was more of a guess/codejacking. My plan, Mark, actually was to send a byte array to a php script that acted as a web service. Unfortunately, I've never dealt with file transfers and as such, I don't even know how to do that! lol I'm at ground zero.


string localFile;
string uploadUrl;


Expand|Select|Wrap|Line Numbers
  1.             try
  2.             {
  3.  
  4.                 FileStream rdr = new FileStream(localFile, FileMode.Open);
  5.                 byte[] inData = new byte[4096];
  6.                 int totbytes = 0;
  7.                 MemoryStream postData = new MemoryStream();
  8.                 int bytesRead = rdr.Read(inData, 0, inData.Length);
  9.                 while (bytesRead > 0)
  10.                 {
  11.                     postData.Write(inData, 0, bytesRead);
  12.                     bytesRead = rdr.Read(inData, 0, inData.Length);
  13.                     totbytes += bytesRead;
  14.                 }
  15.                 rdr.Close();
  16.                 postData.Position = 0;
  17.                 HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uploadUrl);
  18.                 req.Method = "POST";
  19.                 req.ContentLength = (long)postData.Length;
  20.                 using (Stream s = req.GetRequestStream())
  21.                 {
  22.                     s.Write(postData.ToArray(), 0, (int)postData.Length);
  23.                     postData.Close();
  24.                 }
  25.                 WebResponse resp = req.GetResponse();
  26.                 resp.Close();
  27.             }
  28.             catch (Exception ex)
  29.             {
  30.             }
  31.             finally
  32.             {
  33.             }
Nov 14 '08 #4
Cyprus106
31 New Member
If anybody has any ideas, I would still appreciate it. I'm sadly still kind of stuck on this problem.
Dec 1 '08 #5
markmcgookin
648 Recognized Expert Contributor
Cyprus,

The easiest way to add a web service call to any .Net application is to make sre that the web service is externally exposed (i.e. available to connections) then use visual studio to add a web reference to your web service. Then all you have to do is create an instance of your web service then call your web method. It saves you manually invoking http requests etc.
Dec 3 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2660
by: NotGiven | last post by:
Please help me understand the big picture of allowing users to upload pictures and keep them separate and tied to their record in the database. I want the whole thing automated and I'm just trying to get my arms around what all is entailed. Each user will upload about 20 - 100 pictures and each will be related to a different database record. I see the process in general as this:
2
2486
by: Oli | last post by:
Hi Currently I have a simple form where users input and update their data. This works fine. However, we now have a need for users to be able to upload a picture to their profile. I have managed to successfully do this, however, once the picture is uploaded I need it to be automatically resized and renamed in the format "username.jpg". Then I need the path of the picture to be stored in the database with their record so that when it...
1
3159
by: alfredfx | last post by:
i'm planning to develop a client server system the client and server both able to upload picture client will upload the picture to a folder that reside in the server while server user can also upload picture to that folder also and then client and server can retrieve the picture from there. can someone giv some guide to me how to work this out ? i'v been lookin for solution. 1. using sqldatabase to store picture 2. ....
3
2978
by: samoore | last post by:
Can you upload an image using a windows app. I either want to upload the image to a database or just a folder, but all of my searches show that you have to use a web app. I want to do this with a win app. Any help would be appreciated. Samoore33
21
34440
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most obvious of which is the sharing of files. For example, you upload images to a server to share them with other people over the Internet. Perl comes ready equipped for uploading files via the CGI.pm module, which has long been a core module and allows users...
7
3733
by: dragiton | last post by:
SA Upload SQL Database variable types (image upload and storage) I am having trouble with the SA Upload utility. The following code used to work correctly. However, I lost my database and had to rebuild. Does anyone have any suggestions on what I may have wrong. I am not sure if I built my table to store the picture id's correctly. Maybe a field type or something. <form name="UpdatePropertyPicture" method="POST"...
4
1862
by: Cyprus106 | last post by:
I realize how I'm going about this is somewhat odd. I have to construct a program for windows mobile that only sends a couple queries to a remote MySQL server and hopefully gets some success/fail returns. (I've got VS2008 pro and the winmobile SDKs) The 2 problems I have: 1) I'm very well versed in C++, and I know a little C#. I managed to compile some simple winmobile programs, but I'd be more comfortable grabbing a couple of walkthroughs...
3
2216
by: Cyprus106 | last post by:
I'm doing some geolocative work and do not, as of yet, have a map that I'm using in winmobile 6 SDK. I'd like to sync a map with some points up in the winmobile app. I'm wondering who knows where I should start, what map SDK to use, and if there's any particular pitfalls to avoid, points to consider, etc. Thanks a lot!
0
1051
by: simon2x1 | last post by:
i have an upload page called upload.php and a display upload called display.php while i make use of my wamp server on my localhost and i access upload.php to upload an image the image go to a folder called picture and the image in this folder will display if i access the display.php page. now i have a webhost, in my file manager i have uploaded the two pages and i create the folder picture, if i visit my URL and i upload an image, the image will...
0
10370
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10177
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9969
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8995
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5402
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4074
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2896
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.