File uploading issue

Discussion in 'ASP.NET / ASP.NET Core' started by Rookie, Mar 5, 2006.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I am having an issue when trying to upload files to the server and the information to my database. The files are created but they are blank. I feel like the uploading process is timing out because the no information is being written to the database.
    This is strange because everything works on my home machine but after I upload it I am having this issue. Below is the code (c#) that I am using:

    private void lnkAddMusic_Click(object sender, System.EventArgs e)
    {
    try
    {
    if(musicFileName.PostedFile != null)
    {
    DataTable dt = ViewState["BandInfo"] as DataTable;
    decimal musicID = -1;
    string bandName = Convert.ToString(dt.Rows[0]["BAN_NAME"]);
    string musicName = Path.GetFileName(musicFileName.PostedFile.FileName);
    string msuic = musicName.Substring(0, musicName.LastIndexOf("."));
    string fileName = Convert.ToString(ViewState["_bandID"]) + "_" + musicName;
    string saveLoaction = Server.MapPath("songs");
    //string saveLoaction = Server.MapPath("songs") + @"\" + bandName;
    bool isNotInList = true;
    foreach(ListItem li in lsSongs.Items)
    {
    string musicText = GetRidOfTail(li.Text);
    if(musicText.ToUpper() == msuic.ToUpper())
    {
    isNotInList = false;
    break;
    }
    }
    if((isNotInList) &amp;&amp; lsSongs.Items.Count < 50)
    {
    HttpPostedFile myFile = musicFileName.PostedFile;
    int contentLen = myFile.ContentLength;
    byte [] musicData = new byte[contentLen];
    myFile.InputStream.Read(musicData, 0, contentLen);
    SaveMusicFile(saveLoaction, fileName, ref musicData);

    //musicFileName.PostedFile.SaveAs(saveLoaction);
    musicID = MusicAdd(Convert.ToDecimal(cboGenre.SelectedValue), Convert.ToDecimal(ViewState["_bandID"]),
    msuic, fileName, @"songs\");
    DisplayBandSongs(Convert.ToDecimal(ViewState["_bandID"]));
    }
    }
    }
    catch(Exception ex)
    {
    alert(ex.Message);
    }
    }
     
  2. Thanks Joel, I didn't realize that I needed to allocate specific space for "apsnet user" and "iusr".

    That solved it[​IMG]
     
  3. What are "aspnet user" and "iusr"?

     
  4. Takeshi Eto

    Takeshi Eto DiscountASP.NET Staff

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page