473,549 Members | 2,366 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Hi,
I've been trying to upload file using webclient.uploa dfile 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.uploa dfile 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 2292
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.t xt") and I also tried
wc.uploadfile(" http://sample.com/getFile.php", "c:\temp\text.t xt"),
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:\In etpub\wwwroot\U pload\myFile.tx t"
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********@gma il.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
| Hi,
| I've been trying to upload file using webclient.uploa dfile 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.uploa dfile 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********@gmai l.com wrote:
Hi,
I've been trying to upload file using webclient.uploa dfile 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.uploa dfile 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.Uploa dFile() 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.d e
Jul 21 '05 #5

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

Similar topics

3
2064
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) I have a simple php script, getFile.php to receive the file. The script look like this: <?php $uploadDir = '/var/www/Incoming/'; $uploadFile =...
5
7819
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 files via FTP. I'm using ftplib to do it, and for each file I'm using transfercmd("STOR " + myfile) to get the socket, then uploading 4096 bytes at...
7
2367
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... There's been a problem with your request exceptions.ValueError: invalid distribution file I have managed to upload a Windows installer, and...
4
1509
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) I have a simple php script, getFile.php to receive the file. The script look like this: <?php $uploadDir = '/var/www/Incoming/'; $uploadFile...
13
4285
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 that this is suppossed to end up as a component for others to use, and therefore I do NOT have access to their global.cs::Session_End() how do I...
0
1511
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 = file.ContentLength; byte fileContent = new byte; int lastPos = file.FileName.LastIndexOf('\\');
5
2711
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 more documents to share/use during a meeting presentation. What would be the most efficient way to approach this? This is the logic I'm currently...
1
4405
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 would give it a try. First of all, I am using Visual Studio 2005 to write my program. I am using C# .NET as the language. I am running Windows XP...
0
7740
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
7503
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
7830
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
6071
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
5387
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
3517
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...
1
1962
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
1
1082
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
784
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.