473,386 Members | 1,652 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,386 software developers and data experts.

Uploading file to a different web platform using ASP.NET/VB.NET

Hi,
I've been trying to upload file using webclient.uploadfile method
from my IIS webserver to an Apache webserver without any success. On
the Apache server (server that receives the incoming file) I have a
simple php script, getFile.php to receive the file. The script look
like this:

<?php
$uploadDir = '/var/www/Incoming/';
$uploadFile = $uploadDir . $_FILES['userfile']['name'];
print "<pre>";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadFile))
{
print "File is valid, and was successfully uploaded. ";
print "Here's some more debugging info:\n";
print_r($_FILES);
}
else
{
print "Error receiving file:\n";
print_r($_FILES);
}
print "</pre>";
?>

I know this script work perfectly if I use a standard html with <input
type="file"> method. However, file needs to be sent from an
asp.net page instead of html. People on the newsgroup have been
suggesting me to use webclient.uploadfile method, however, I just could
not get it to work.

Perhaps there is something wrong with my php script or maybe there
something else needs to be done to the webclient. If anybody has came
across with the similar situation, can you show me how to do it both on
the ASP.NET side and php side (or perl)
Thanks
Brian

Jul 21 '05 #1
4 2282
This aspect of the question would best be suited in a php
newsgroup/community. If you have related ASP.NET code using the
UploadFile method then you can post that here.

Jul 21 '05 #2
It might be a php and ASP.NET question and that's why I have it posted
here.

In my asp.net form I have

wc as new webclient
wc.uploadfile("http://sample.com/getFile.php", "POST",
"c:\temp\text.txt") and I also tried
wc.uploadfile("http://sample.com/getFile.php", "c:\temp\text.txt"),
non of them returned any error, however the file never get uploaded.

thanks
Brian

Jul 21 '05 #3
i haven't tested (use an network sniff or create a dump page), but suspect
the name is not correct. the standard format is

-----------------------------7d01ecf406a6
Content-Disposition: form-data; name="myfile";
filename="C:\Inetpub\wwwroot\Upload\myFile.txt"
Content-Type: text/plain

this is some test data

-----------------------------7d01ecf406a6

name equals the the name of the input file control in the html version

<input type=file name="myfile>

filename is the name of the file selected.

as the webclient control does not allow to to specify the formdata name, it
is either leaving it out or making one up. but your php script probably
requies it.

-- bruce (sqlwork.com)
<br********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
| Hi,
| I've been trying to upload file using webclient.uploadfile method
| from my IIS webserver to an Apache webserver without any success. On
| the Apache server (server that receives the incoming file) I have a
| simple php script, getFile.php to receive the file. The script look
| like this:
|
| <?php
| $uploadDir = '/var/www/Incoming/';
| $uploadFile = $uploadDir . $_FILES['userfile']['name'];
| print "<pre>";
| if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadFile))
| {
| print "File is valid, and was successfully uploaded. ";
| print "Here's some more debugging info:\n";
| print_r($_FILES);
| }
| else
| {
| print "Error receiving file:\n";
| print_r($_FILES);
| }
| print "</pre>";
| ?>
|
| I know this script work perfectly if I use a standard html with <input
| type="file"> method. However, file needs to be sent from an
| asp.net page instead of html. People on the newsgroup have been
| suggesting me to use webclient.uploadfile method, however, I just could
| not get it to work.
|
| Perhaps there is something wrong with my php script or maybe there
| something else needs to be done to the webclient. If anybody has came
| across with the similar situation, can you show me how to do it both on
| the ASP.NET side and php side (or perl)
|
|
| Thanks
| Brian
|
Jul 21 '05 #4
br********@gmail.com wrote:
Hi,
I've been trying to upload file using webclient.uploadfile method
from my IIS webserver to an Apache webserver without any success. On
the Apache server (server that receives the incoming file) I have a
simple php script, getFile.php to receive the file. The script look
like this:

<?php
$uploadDir = '/var/www/Incoming/';
$uploadFile = $uploadDir . $_FILES['userfile']['name'];
print "<pre>";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadFile))
{
print "File is valid, and was successfully uploaded. ";
print "Here's some more debugging info:\n";
print_r($_FILES);
}
else
{
print "Error receiving file:\n";
print_r($_FILES);
}
print "</pre>";
?>

I know this script work perfectly if I use a standard html with <input
type="file"> method. However, file needs to be sent from an
asp.net page instead of html. People on the newsgroup have been
suggesting me to use webclient.uploadfile method, however, I just
could not get it to work.

Perhaps there is something wrong with my php script or maybe there
something else needs to be done to the webclient. If anybody has came
across with the similar situation, can you show me how to do it both
on the ASP.NET side and php side (or perl)


This is a bug in WebClient.UploadFile() that exists since .NET 1.0. It
does not create a syntactically correct multipart/form-data request.
You'll have to use WebRequest instead and build your own
multipart/form-data request.

Cheers,

--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Jul 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: brianinbox | last post by:
Hi, I've been trying to upload file using webclient.uploadfile method from my IIS webserver to an Apache webserver without any success. On the Apache server (server that receives the incoming file)...
5
by: Kevin Ollivier | last post by:
Hi all, I've come across a problem that has me stumped, and I thought I'd send a message to the gurus to see if this makes sense to anyone else. =) Basically, I'm trying to upload a series of...
7
by: John Machin | last post by:
Sorry in advance if this is not the correct forum ... I'm trying to upload what appears to be a perfectly OK zip file as a "source" file type to PyPI, and am getting this response: Error......
4
by: brianinbox | last post by:
Hi, I've been trying to upload file using webclient.uploadfile method from my IIS webserver to an Apache webserver without any success. On the Apache server (server that receives the incoming...
13
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming...
0
by: TJ | last post by:
Hi, I've written code web-based uploading and downloading. Here is some code for it. For saving file into MS-SQL database, SaveFileIntoDB(HttpPostedFile file) { int fileLength =...
5
by: Chris | last post by:
I have a meetings section I'm developing on our intranet. Using PHP/MySQL. Meeting info and Meeting docs reside on 2 related tables in the db. Users may want to upload anywhere from 1 to 10 or...
1
by: WeCi2i | last post by:
Okay, I have a problem that has been stumping me for weeks. I have tried many different solutions and this is pretty much my last resort. I have seen a lot of good answers give here so I figured I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...

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.