File Uploading

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Vajrala Narendra
    New Member
    • Jun 2007
    • 73

    File Uploading

    Hi all
    am using asp.net 2.0, c#

    i have a fileupload, hyperlink controls
    i want to to upload hyperlink's navigate url
    i wrote code as below

    FileUpload1.Pos tedFile.FileNam e = HyperLink1.Navi gateUrl;


    but it is giving error as: Property or indexer 'System.Web.Htt pPostedFile.Fil eName' cannot be assigned to -- it is read only

    how to upload hyperlinks url

    Please suggest

    Thanks inadvance
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    This doesn't make sense to me at all. FileUpload is made for browser clients to upload files from their local machine, not for you to assign a web url to their uploaded file.

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      You are not allowed to set the File Name property of a FileUploadContr ol. This is why you are getting the error you are seeing.

      InsertAlias is correct at pointing out that this control is not designed to do what you are attempting.

      Please provide more details on the problem you are attempting to solve so that we can point you to a control that can help you in your solution.

      -Frinny

      Comment

      • Vajrala Narendra
        New Member
        • Jun 2007
        • 73

        #4
        i want to send hyperlinks url as an attachment , for that am trying this

        Comment

        • Curtis Rutland
          Recognized Expert Specialist
          • Apr 2008
          • 3264

          #5
          You just want to send the hyperlink? As an email attachment? Hyperlinks aren't files, they are just text.

          You could include the HTML for the correct link in the email.

          Comment

          • Vajrala Narendra
            New Member
            • Jun 2007
            • 73

            #6
            Originally posted by insertAlias
            You just want to send the hyperlink? As an email attachment? Hyperlinks aren't files, they are just text.

            You could include the HTML for the correct link in the email.

            i want to send the file as attachment
            that file was nothing but hyperlinks url
            i wrote as following
            string fadd, toadd, s, att;
            fadd = "";
            toadd = "";
            s = "";
            att = "";
            att = HyperLink1.Navi gateUrl;

            MailMessage M = new MailMessage();
            M.To = toadd;
            M.From = fadd;
            M.Body = s.ToString();
            M.Subject = "Profile";
            attach = new MailAttachment( @att);
            M.Attachments.A dd(attach);
            SmtpMail.Send(M );


            fadd, toadd am retrieving from database

            while executing this i got error as : invalied mail attachment

            please check

            Comment

            • Frinavale
              Recognized Expert Expert
              • Oct 2006
              • 9749

              #7
              Originally posted by Vajrala Narendra
              i want to send the file as attachment
              that file was nothing but hyperlinks url
              i wrote as following
              string fadd, toadd, s, att;
              fadd = "";
              toadd = "";
              s = "";
              att = "";
              att = HyperLink1.Navi gateUrl;

              MailMessage M = new MailMessage();
              M.To = toadd;
              M.From = fadd;
              M.Body = s.ToString();
              M.Subject = "Profile";
              attach = new MailAttachment( @att);
              M.Attachments.A dd(attach);
              SmtpMail.Send(M );


              fadd, toadd am retrieving from database

              while executing this i got error as : invalied mail attachment

              please check
              The reason you get this error is because you cannot attach a hyperlink to an email.......att achments to emails are files.

              If you are developing an ASP.NET web application that sends an email with an attachment specified by the user you are going to have to place a FileUpload control on the page and write the code that uploads the file to the server. Please see this article for information on the FileUpload control and how to implement it.

              Once the file is uploaded to the server you can attach it to your email.

              If you just want to send an email with a hyperlink to a web page....then in your email body write the HTML that links to that web page...

              Eg:
              [code=html]
              <a href="http://theUrlOfTheSite .com/">Text you want them to see in the email</a>[/code]

              -Frinny

              Comment

              Working...