Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ..."File upload" code wanted."File upload" code wanted.
Previous
 
Next
New Post
3/22/2008 11:45 AM
 

 

Hi all,

I need a piece of code to upload files from a personal PC (my portal users) to my webportal.

I dit tried to use this code:

File.Copy(strUploadFileOrg, strUploadFileDest)

but testing shows that it only works on my local development webportal, i.e. when the directory structure is the same for the sending (strUploadFileOrg) and receiving (strUploadFileDest) environment. If I want to send a file to my portal that is located at my hosting porvider, but this doesn't work, because the hosting directory don't match mine, let alone the directories of my users who must be able to upload their files.

I dit try to implement the "standard" upload control, but I don't want the user to select the destinaton directory on the portal side; the directory structure is part of the solution, and therefore can't be "freely" exposed to the user; too many change that errors will occur. So I need a routine (JAVA?) that can send a locally selected file to my pre-defined directory on the hosting web-server.

Can somebody help me with a hint or a piece of code to get this job done properly, please?

Jos

 


jos Richters www.visualdata.nl
 
New Post
3/22/2008 1:24 PM
 

ascx

<INPUT id="hifPoint" type="file" name="hifPoint" runat="server"> <INPUT id="cmdUpload" type="submit" value="Upload" name="cmdUpload" runat="server">

C# Code Behind

private void cmdUpload_ServerClick(object sender, System.EventArgs e)
{
            System.IO.Stream st;
            System.IO.StreamReader sr;
           
            st = hifPoint.PostedFile.InputStream;
            sr = new System.IO.StreamReader(st);

            //Do Things With File - using sr.

            hifPoint.PostedFile.SaveAs("Your Server Path Here");
}

 

That's what I've been using.

 
New Post
3/22/2008 1:48 PM
 

Thanks Baatezu,

I work with VB.NET, not C#.

Wat should the code be in VB, please?

sincerely,

Jos


jos Richters www.visualdata.nl
 
New Post
3/22/2008 4:27 PM
 

I think it would be something like

Private Sub cmdUpload_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim st As System.IO.Stream
    Dim sr As System.IO.StreamReader
  
    st = hifPoint.PostedFile.InputStream
    sr = New System.IO.StreamReader(st)
  
    'Do Things With File - using sr.
   
    hifPoint.PostedFile.SaveAs("Your Server Path Here")
End Sub

 

I use http://labs.developerfusion.co.uk/convert/vb-to-csharp.aspx to do conversions for my lazy bum.

 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ..."File upload" code wanted."File upload" code wanted.


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out