473,320 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Upload picture from winmobile (C#) using php

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 2927
RedSon
5,000 Expert 4TB
What have you already tried?
Nov 13 '08 #2
markmcgookin
648 Expert 512MB
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
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
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 Expert 512MB
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
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...
2
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...
1
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...
3
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...
21
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...
7
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...
4
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...
3
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...
0
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.