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

Flash File Upload in FTP site through Webpage

HI. Any One already fix this following problem? I have to upload a swf banner for my site at runtime. I have tried with FTPwebrequest class. The complete code here..
Expand|Select|Wrap|Line Numbers
  1. btnUpload_click()
  2. {
  3. string FtpUrl = "ftp://sitename/httpdocs/banner/BANNER.swf";
  4.      string filename = "fuBanner.PostedFile.FileName";
  5.  
  6.         FtpUpload objFtpUpload = new FtpUpload();
  7.           try
  8.            {
  9.              objFtpUpload.Upload(filename, FtpUrl, "UserName", "Password");
  10.              lblmsg.Text = "Uploaded";
  11.         }
  12.           catch(Exception ex)
  13.    {
  14.              lblmsg.Text =ex.Message;
  15.          }
  16.       }
  17.  
  18.  
  19. public class FtpUpload
  20. {
  21.     public void Upload(string filename, string FtpUrl,string UserName,string Password)
  22.     {
  23.         FileInfo fileInf = new FileInfo(filename);
  24.         FtpWebRequest reqFTP;
  25.         reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(FtpUrl));
  26.  
  27.  
  28.         reqFTP.Credentials = new NetworkCredential(UserName,Password);
  29.  
  30.  
  31.         reqFTP.Proxy = null;
  32.  
  33.  
  34.         reqFTP.KeepAlive = false;
  35.  
  36.         reqFTP.Method = WebRequestMethods.Ftp.UploadFile;
  37.  
  38.  
  39.         reqFTP.UseBinary = true;
  40.  
  41.  
  42.         reqFTP.ContentLength = fileInf.Length;
  43.  
  44.  
  45.         int buffLength = 2048;
  46.         byte[] buff = new byte[buffLength];
  47.         int contentLen;
  48.  
  49.  
  50.         FileStream fs = fileInf.OpenRead();
  51.  
  52.  
  53.  
  54.         Stream strm = reqFTP.GetRequestStream();
  55.  
  56.  
  57.         contentLen = fs.Read(buff, 0, buffLength);
  58.  
  59.  
  60.         while (contentLen != 0)
  61.         {
  62.  
  63.             strm.Write(buff, 0, contentLen);
  64.             contentLen = fs.Read(buff, 0, buffLength);
  65.         }
  66.  
  67.  
  68.         strm.Close();
  69.         fs.Close();
  70.  
  71.  
  72.     }
  73. }
In the above code working well in local host. But When try to upload banner through webpage(that means from ftp site) it throws an exception as Could not find file .ie try to upload d:\\banner.swf. it throws exception Could not find file "D:\\Banner.swf". i think it couldnt identify client machine path .(loacl machine path). i need to upload from the website only. how to fix this problem...
Nov 4 '07 #1
0 1044

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

Similar topics

1
by: Eric | last post by:
I have the following code I am calling from a flash file. Everything works fine except that the string it returns for the file location does not include the slashes. It is returning...
2
by: dnc28 | last post by:
Hi! Have a look at these sites. http://www.untitledstudio.com/flash.htm http://www.uniform.net/index2.html Both these sites have a Flash .swf file embedded into a HTML webpage.
4
by: Shawn Mesiatowsky | last post by:
I have an html form that accepts a file for uploading, but I wanted to create a program to automate the upload procedure. I beileive you use the Webresponse class, but I was not sure how to use...
5
by: Grace | last post by:
Hello, I want to upload the file by webpage to SQL Server. When I upload the small file, it is work. But, when I upload big file(ex. 40~50 MB), it isn't work; the Browser displays the...
2
by: Jim Lewis | last post by:
I need to upload files to a Web server from Flash MX. Flash does not have the ability to upload files. I have an example that uses a PHP page in the back ground to upload files...
2
by: Nicole Legroe | last post by:
I have an asp.NET site running. I want to make it possible in my webpage, to enter the name of an imagefile on my computer and to upload this file on my webserver. What is the code to make this...
18
by: jmd | last post by:
Hello, I posted the following in the C# forum but without one answer. But perhaps now in vb.net someone has some guidelines ! This is my question : I want to write a vb.net program that does...
11
by: emailus | last post by:
I am webmaster for the domain <www.alpha1.org.au>. Not being an expert in html, I take advantage of my domain Registrant's web building tool, 'Instant Website'. This tool is provided as part of...
0
by: Shaikh shahnawaz | last post by:
Hi, I have implement multiple file uploading progress bar with the help of flash and .net file is upload on my local machine but not working with server it's give error while uploading image on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
0
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,...

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.