473,586 Members | 2,495 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Upload image file in Windows Phone 7 Application to PHP

1 New Member
I am trying to upload a picture from the Pictures Library (on WP7) and save it in a folder on the server.

On the server, I'm using PHP to receive the file using POST Method. The PHP Code is:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $uploads_dir = 'files/'; //Directory to save the file that comes from client application.
  3. if ($_FILES["file"]["error"] == UPLOAD_ERR_OK) {
  4.     $tmp_name = $_FILES["file"]["tmp_name"];
  5.     $name = $_FILES["file"]["name"];
  6.     move_uploaded_file($tmp_name, "$uploads_dir/$name");
  7. }
  8. ?>
I've already tried some approaches, but they all just seem to fail. I've already done this job in a Windows Forms application using the Client.UploadFi le method but it seems that it cannot be used on a Windows Phone Application.

I think httpwebrequest can help, right?

This is my C# code so far:
Expand|Select|Wrap|Line Numbers
  1. public partial class SamplePage : PhoneApplicationPage
  2.     {
  3.         public SamplePage()
  4.         {
  5.             InitializeComponent();
  6.         }
  7.  
  8.         PhotoChooserTask selectphoto = null;
  9.  
  10.         private void SampleBtn_Click(object sender, RoutedEventArgs e)
  11.         {
  12.             selectphoto = new PhotoChooserTask();
  13.             selectphoto.Completed += new EventHandler<PhotoResult>(selectphoto_Completed);
  14.             selectphoto.Show();
  15.         }
  16.  
  17.         void selectphoto_Completed(object sender, PhotoResult e)
  18.         {
  19.             if (e.TaskResult == TaskResult.OK)
  20.             {
  21.                 BinaryReader reader = new BinaryReader(e.ChosenPhoto);
  22.                 image1.Source = new BitmapImage(new Uri(e.OriginalFileName));
  23.                 txtBX.Text = e.OriginalFileName;
  24.             }
  25.         }
  26.     }
I read it somewhere that the image is required to be converted to a string of bytes, I don't know for sure. But, please help me.

Thanks a lot in advance.
Mar 19 '13 #1
0 2012

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

Similar topics

4
6262
by: Martin | last post by:
Hi, I search for free script to enable function UPLOAD Images, Files to Webserver, and save in a directory. I have tried a free script, but it doesn't work. (http://www.freeaspupload.net), when I try the example of this page it does, but with my pages it does not. Thanks Martin
1
4320
by: Patsy | last post by:
Hi I'm using a third party software which captures image from a webcam and saves it to local harddisk. It also comes with a function to send the image file via HTTP encoded with multipart/form-data. To integrate this function with ASP and PHP is no problem. I think it's also possible to binary read and decode the files and fields posted, in...
1
3075
by: Daniel Mark | last post by:
Hello all: I have following code that works well under command line, but it doesn't work after I convert it as exe application. ############### file: testPath.py import getopt, math, sys, os, Image, ImageDraw, aggdraw def processline():
3
2967
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
3
2006
by: wingleader | last post by:
Hi! Can someone help? I need to store image files in mysql database. Can you help with advice, how can it be done? I need a possibility to upload images, and that late it could be read as an image.
0
1991
by: aris1234 | last post by:
hello.. How to upload image file in page update ..?? i have logic like this : if user upload new image then old image must delete and update DB used new name if user not upload new image then old image no delete. code form like this (i dontknow this code right or wrong, please correction if wrong) :
3
1841
by: Sanjya | last post by:
i have made windows apllication in .net C# but there are some probelm of flickering image when i open this application please give me the solution
8
5645
by: Anuhas | last post by:
Dear Experts, My project involves developing a Windows Application where i need to load a picture and i used the following code, Bitmap myBitmap3 = new Bitmap(@"C:\App\images\logo.bmp"); however, this is not convenient as if i try to use the same project folder in another pc, it doesn't work. so i tried the following, Bitmap myBitmap3...
3
4410
by: premprakashbhati | last post by:
hi, good evening.. i am going to upload an image in a web form .....for that iam using HTML input(file) control and one web control button i.e., Upload_Button() here is the code ...its work fine when iam using a normal web page... but can't in content page.... Code in Master Page <%@ Master Language="C#" AutoEventWireup="true"...
2
4429
by: sidhx | last post by:
how can i let image overwriting when uploading? and if uploading an image say "logo.jpg" and if a file already existing say "logo.png" then, how can i replace the file logo.png to logo.jpg(which has same name but different extension)? Ex: I want replace logo.jpg with logo.png or any image extension file. In my code while uploading the image...
0
7915
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8204
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. ...
1
7965
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8220
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...
0
6617
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...
1
5712
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1184
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...

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.