Exemple #1
0
    protected void LinkButton1A_Click(object sender, EventArgs e)
    {
        RadUploadContext upContext = RadUploadContext.Current;
        string           faudio    = "";
        string           diraudio  = Server.MapPath("~/App_Uploads_Audio/");

        if (RadUploadAudio.UploadedFiles.Count > 0)
        {
            foreach (UploadedFile fileaudio in RadUploadAudio.UploadedFiles)
            {
                if (fileaudio.FileName.Contains("'"))
                {
                    faudio = fileaudio.FileName.Replace("'", "");
                }
                else
                {
                    faudio = fileaudio.FileName;
                }
                if ((DropDownList1A.SelectedIndex == 0) && (tbDirectoryAudio.Text.Length == 0))
                {
                    Session["cataudio"]   = null;
                    Session["Filesaudio"] = null;
                    TabPanel3Audio.Focus();
                }
                else if ((DropDownList1A.SelectedIndex == 0) && (tbDirectoryAudio.Text.Length > 0))
                {
                    Directory.CreateDirectory(diraudio + tbDirectoryAudio.Text);
                    fileaudio.SaveAs(Server.MapPath("~/App_Uploads_Audio/" + tbDirectoryAudio.Text + "/" + faudio), true);
                    Session["cataudio"]   = tbDirectoryAudio.Text;
                    Session["Filesaudio"] = faudio;
                }

                else if ((DropDownList1A.SelectedIndex != 0) && (tbDirectoryAudio.Text.Length > 0))
                {
                    Directory.CreateDirectory(diraudio + DropDownList1A.SelectedItem.Text + "/" + tbDirectoryAudio.Text);
                    fileaudio.SaveAs(Server.MapPath("~/App_Uploads_Audio/" + DropDownList1A.SelectedItem.Text + "/" + tbDirectoryAudio.Text + "/" + faudio), true);
                    Session["cataudio"]   = DropDownList1A.SelectedItem.Text + "/" + tbDirectoryAudio.Text;
                    Session["Filesaudio"] = faudio;
                }

                else if ((DropDownList1A.SelectedIndex > 0) && (tbDirectoryAudio.Text.Length == 0))
                {
                    fileaudio.SaveAs(Server.MapPath("~/App_Uploads_Audio/" + DropDownList1A.SelectedItem.Text + "/" + faudio), true);

                    Session["cataudio"]   = DropDownList1A.SelectedItem.Text;
                    Session["Filesaudio"] = faudio;
                }
                GC.Collect();
            }
        }

        getfolders(ref al, Server.MapPath("~/App_Uploads_Audio/"));
        getallfolders(ref al2, Server.MapPath("~/App_Uploads_Audio/"));


        UpdatePanel1Audio.Update();
        UpdatePanel2Audio.Update();
        getcontent();
    }
    protected void LinkButton1D_Click(object sender, EventArgs e)
    {
        RadUploadContext upContext = RadUploadContext.Current;

        string dirdoc = Server.MapPath("~/App_Uploads_Docs/");

        if (RadUploadDoc.UploadedFiles.Count > 0)
        {
            foreach (UploadedFile filedoc in RadUploadDoc.UploadedFiles)
            {
                if ((DropDownList1D.SelectedIndex == 0) && (tbDirectoryDoc.Text.Length == 0))
                {
                    Session["catdoc"]   = null;
                    Session["Filesdoc"] = null;
                    TabPanel3Docs.Focus();
                }
                else if ((DropDownList1D.SelectedIndex == 0) && (tbDirectoryDoc.Text.Length > 0))
                {
                    Directory.CreateDirectory(dirdoc + tbDirectoryDoc.Text);
                    filedoc.SaveAs(Server.MapPath("~/App_Uploads_Docs/" + tbDirectoryDoc.Text + "/" + filedoc.GetName()), true);
                    Session["catdoc"]   = tbDirectoryDoc.Text;
                    Session["Filesdoc"] = filedoc.GetName();
                }

                else if ((DropDownList1D.SelectedIndex != 0) && (tbDirectoryDoc.Text.Length > 0))
                {
                    Directory.CreateDirectory(dirdoc + DropDownList1D.SelectedItem.Text + "/" + tbDirectoryDoc.Text);
                    filedoc.SaveAs(Server.MapPath("~/App_Uploads_Docs/" + DropDownList1D.SelectedItem.Text + "/" + tbDirectoryDoc.Text + "/" + filedoc.GetName()), true);
                    Session["catdoc"]   = DropDownList1D.SelectedItem.Text + "/" + tbDirectoryDoc.Text;
                    Session["Filesdoc"] = filedoc.GetName();
                }

                else if ((DropDownList1D.SelectedIndex > 0) && (tbDirectoryDoc.Text.Length == 0))
                {
                    filedoc.SaveAs(Server.MapPath("~/App_Uploads_Docs/" + DropDownList1D.SelectedItem.Text + "/" + filedoc.GetName()), true);

                    Session["catdoc"]   = DropDownList1D.SelectedItem.Text;
                    Session["Filesdoc"] = filedoc.GetName();
                }
            }
        }


        getfolders(ref al, Server.MapPath("~/App_Uploads_Docs/"));

        UpdatePanel1Doc.Update();
        UpdatePanel2Doc.Update();
        getcontentdoc();
    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        RadUploadContext upContext = RadUploadContext.Current;
        string           dir       = Server.MapPath("~/App_Uploads_Img/");

        if (RadUpload1.UploadedFiles.Count > 0)
        {
            foreach (Telerik.Web.UI.UploadedFile file in RadUpload1.UploadedFiles)
            {
                string name = file.GetName().ToLower();
                name = name.Replace(" ", "_");
                name = name.Replace("%20", "_");
                name = name.Replace("#", "");
                if ((DropDownList1I.SelectedIndex == 0) && (tbDirectoryImage.Text.Length == 0))
                {
                    Session["cat"]   = null;
                    Session["Files"] = null;
                    TabPanel3.Focus();
                }
                else if ((DropDownList1I.SelectedIndex == 0) && (tbDirectoryImage.Text.Length > 0))
                {
                    Directory.CreateDirectory(dir + tbDirectoryImage.Text);

                    // Save original high res, we'll use this for our resizing then delete it after
                    string physicalpath = Server.MapPath("~/App_Uploads_Img/" + tbDirectoryImage.Text + "/");
                    file.SaveAs(physicalpath + name, true);

                    string path    = tbDirectoryImage.Text + "/";
                    string width1  = ResizeWidth1;
                    string height1 = ResizeHeight1;
                    string prefix1 = ResizePrefix1;
                    string suffix1 = ResizeSuffix1;

                    string width2  = ResizeWidth2;
                    string height2 = ResizeHeight2;
                    string prefix2 = ResizePrefix2;
                    string suffix2 = ResizeSuffix2;

                    string width3  = ResizeWidth3;
                    string height3 = ResizeHeight3;
                    string prefx3  = ResizePrefix3;
                    string suffix3 = ResizeSuffix3;

                    // Begin resize function
                    resize(name, path, physicalpath, width1, height1, prefix1, suffix1);
                    resize(name, path, physicalpath, width2, height2, prefix2, suffix2);
                    //resize(name, path, physicalpath, width3, height3, prefix3, suffix3);

                    Session["cat"] = tbDirectoryImage.Text;
                    string sFileName = file.GetName().ToLower();
                    string na        = sFileName.Substring(0, sFileName.LastIndexOf("."));
                    string format    = sFileName.Substring(na.Length);
                    if (prefix2 != "")
                    {
                        prefix2 += "_";
                    }
                    if (suffix2 != "")
                    {
                        suffix2 = "_" + suffix2;
                    }
                    sImageName       = prefix2 + na + suffix2 + format;
                    Session["Files"] = sImageName;
                }

                else if ((DropDownList1I.SelectedIndex != 0) && (tbDirectoryImage.Text.Length > 0))
                {
                    Directory.CreateDirectory(dir + DropDownList1I.SelectedItem.Text + "/" + tbDirectoryImage.Text);

                    // Save original high res, we'll use this for our resizing then delete it after
                    string physicalpath = Server.MapPath("~/App_Uploads_Img/" + DropDownList1I.SelectedItem.Text + "/" + tbDirectoryImage.Text + "/");
                    file.SaveAs(physicalpath + name, true);

                    string path    = tbDirectoryImage.Text + "/";
                    string width1  = ResizeWidth1;
                    string height1 = ResizeHeight1;
                    string prefix1 = ResizePrefix1;
                    string suffix1 = ResizeSuffix1;

                    string width2  = ResizeWidth2;
                    string height2 = ResizeHeight2;
                    string prefix2 = ResizePrefix2;
                    string suffix2 = ResizeSuffix2;

                    string width3  = ResizeWidth3;
                    string height3 = ResizeHeight3;
                    string prefx3  = ResizePrefix3;
                    string suffix3 = ResizeSuffix3;

                    // Begin resize function
                    resize(name, path, physicalpath, width1, height1, prefix1, suffix1);
                    resize(name, path, physicalpath, width2, height2, prefix2, suffix2);
                    //resize(name, path, physicalpath, width3, height3, prefix3, suffix3);

                    Session["cat"] = (DropDownList1I.SelectedItem.Text + "/" + tbDirectoryImage.Text);
                    string sFileName = file.GetName().ToLower();
                    string na        = sFileName.Substring(0, sFileName.LastIndexOf("."));
                    string format    = sFileName.Substring(na.Length);
                    if (prefix2 != "")
                    {
                        prefix2 += "_";
                    }
                    if (suffix2 != "")
                    {
                        suffix2 = "_" + suffix2;
                    }
                    sImageName       = prefix2 + na + suffix2 + format;
                    Session["Files"] = sImageName;
                }

                else if ((DropDownList1I.SelectedIndex > 0) && (tbDirectoryImage.Text.Length == 0))
                {
                    // Save original high res, we'll use this for our resizing then delete it after
                    string physicalpath = Server.MapPath("~/App_Uploads_Img/" + DropDownList1I.SelectedItem.Text + "/");
                    file.SaveAs(physicalpath + name, true);

                    string path    = tbDirectoryImage.Text + "/";
                    string width1  = ResizeWidth1;
                    string height1 = ResizeHeight1;
                    string prefix1 = ResizePrefix1;
                    string suffix1 = ResizeSuffix1;

                    string width2  = ResizeWidth2;
                    string height2 = ResizeHeight2;
                    string prefix2 = ResizePrefix2;
                    string suffix2 = ResizeSuffix2;

                    string width3  = ResizeWidth3;
                    string height3 = ResizeHeight3;
                    string prefx3  = ResizePrefix3;
                    string suffix3 = ResizeSuffix3;

                    // Begin resize function
                    resize(name, path, physicalpath, width1, height1, prefix1, suffix1);
                    resize(name, path, physicalpath, width2, height2, prefix2, suffix2);
                    //resize(name, path, physicalpath, width3, height3, prefix3, suffix3);

                    // Assign a session variable so we can auto-select it from the dropdown
                    Session["cat"] = DropDownList1I.SelectedItem.Text;
                    string sFileName = name.ToLower();
                    string na        = sFileName.Substring(0, sFileName.LastIndexOf("."));
                    string format    = sFileName.Substring(na.Length);
                    if (prefix2 != "")
                    {
                        prefix2 += "_";
                    }
                    if (suffix2 != "")
                    {
                        suffix2 = "_" + suffix2;
                    }
                    sImageName       = prefix2 + na + suffix2 + format;
                    Session["Files"] = sImageName;
                }
            }
            GC.Collect();
        }

        getfolders(ref al, Server.MapPath("~/App_Uploads_Img/"));
        getallfolders(ref al2, Server.MapPath("~/App_Uploads_Img/"));
        if ((Session["cat"] != null) && (Session["Files"] != null))
        {
            ddCatImage.SelectedValue = Session["cat"].ToString().Replace("\\", "/");
            getfiles(Server.MapPath("~/App_Uploads_Img/") + ddCatImage.SelectedItem.Value);
            string myfiles = Session["Files"].ToString();
            try
            {
                ddFilesImage.SelectedValue = myfiles.ToLower();
            }
            catch (Exception ex)
            { }
            showimage(ddCatImage.SelectedValue, ddFilesImage.SelectedValue);
        }
        tbDirectoryImage.Text = "";



        //UpdatePanel1Image.Update();
        //UpdatePanel2Image.Update();
    }
    protected void LinkButton1A_Click(object sender, EventArgs e)
    {
        RadUploadContext upContext   = RadUploadContext.Current;
        string           fdocument   = "";
        string           dirdocument = Server.MapPath("~/App_Uploads_Docs/");

        if (RadUploadDocument.UploadedFiles.Count > 0)
        {
            foreach (Telerik.Web.UI.UploadedFile filedocument in RadUploadDocument.UploadedFiles)
            {
                fdocument = filedocument.GetName();
                if (fdocument.Contains("'"))
                {
                    fdocument = fdocument.Replace("'", "");
                }

                if ((DropDownList1D.SelectedIndex == 0) && (tbDirectoryDocument.Text.Length == 0))
                {
                    Session["catdocument"]   = null;
                    Session["Filesdocument"] = null;
                    TabPanel3Document.Focus();
                }
                else if ((DropDownList1D.SelectedIndex == 0) && (tbDirectoryDocument.Text.Length > 0))
                {
                    Directory.CreateDirectory(dirdocument + tbDirectoryDocument.Text);
                    if (!File.Exists(Server.MapPath("~/App_Uploads_Docs/" + tbDirectoryDocument.Text + "/" + fdocument)))
                    {
                        filedocument.SaveAs(Server.MapPath("~/App_Uploads_Docs/" + tbDirectoryDocument.Text + "/" + fdocument), true);
                    }
                    Session["catdocument"]   = tbDirectoryDocument.Text;
                    Session["Filesdocument"] = fdocument;
                }

                else if ((DropDownList1D.SelectedIndex != 0) && (tbDirectoryDocument.Text.Length > 0))
                {
                    Directory.CreateDirectory(dirdocument + DropDownList1D.SelectedItem.Text + "/" + tbDirectoryDocument.Text);
                    if (!File.Exists(Server.MapPath("~/App_Uploads_Docs/" + DropDownList1D.SelectedItem.Text + "/" + tbDirectoryDocument.Text + "/" + fdocument)))
                    {
                        filedocument.SaveAs(Server.MapPath("~/App_Uploads_Docs/" + DropDownList1D.SelectedItem.Text + "/" + tbDirectoryDocument.Text + "/" + fdocument), true);
                    }
                    Session["catdocument"]   = DropDownList1D.SelectedItem.Text + "/" + tbDirectoryDocument.Text;
                    Session["Filesdocument"] = fdocument;
                }

                else if ((DropDownList1D.SelectedIndex > 0) && (tbDirectoryDocument.Text.Length == 0))
                {
                    if (!File.Exists(Server.MapPath("~/App_Uploads_Docs/" + DropDownList1D.SelectedItem.Text + "/" + fdocument)))
                    {
                        filedocument.SaveAs(Server.MapPath("~/App_Uploads_Docs/" + DropDownList1D.SelectedItem.Text + "/" + fdocument), true);
                    }

                    Session["catdocument"]   = DropDownList1D.SelectedItem.Text;
                    Session["Filesdocument"] = fdocument;
                }
                GC.Collect();
            }
        }

        getfolders(ref al, Server.MapPath("~/App_Uploads_Docs/"));
        getallfolders(ref al2, Server.MapPath("~/App_Uploads_Docs/"));


        //UpdatePanel1Document.Update();
        //UpdatePanel2Document.Update();
        getcontent();
    }
Exemple #5
0
    protected void LinkButton1M_Click(object sender, EventArgs e)
    {
        RadUploadContext upContext = RadUploadContext.Current;
        string           moviefile = "";
        string           dir       = Server.MapPath("~/App_Uploads_Movies/");

        if (RadUploadMovie.UploadedFiles.Count > 0)
        {
            foreach (UploadedFile filemov in RadUploadMovie.UploadedFiles)
            {
                if (filemov.FileName.Contains("'"))
                {
                    moviefile = filemov.FileName.Replace("'", "");
                }
                else
                {
                    moviefile = filemov.FileName;
                }
                if ((DropDownList1M.SelectedIndex == 0) && (tbDirectoryMovie.Text.Length == 0))
                {
                    Session["catmovie"]   = null;
                    Session["Filesmovie"] = null;
                    TabPanel3Movie.Focus();
                }
                else if ((DropDownList1M.SelectedIndex == 0) && (tbDirectoryMovie.Text.Length > 0))
                {
                    Directory.CreateDirectory(dir + tbDirectoryMovie.Text);
                    filemov.SaveAs(Server.MapPath("~/App_Uploads_Movies/" + tbDirectoryMovie.Text + "/" + moviefile), true);
                    Session["catmovie"]   = tbDirectoryMovie.Text;
                    Session["Filesmovie"] = moviefile;
                }

                else if ((DropDownList1M.SelectedIndex != 0) && (tbDirectoryMovie.Text.Length > 0))
                {
                    Directory.CreateDirectory(dir + DropDownList1M.SelectedItem.Text + "/" + tbDirectoryMovie.Text);
                    filemov.SaveAs(Server.MapPath("~/App_Uploads_Movies/" + DropDownList1M.SelectedItem.Text + "/" + tbDirectoryMovie.Text + "/" + moviefile), true);
                    Session["catmovie"]   = DropDownList1M.SelectedItem.Text + "/" + tbDirectoryMovie.Text;
                    Session["Filesmovie"] = moviefile;
                }

                else if ((DropDownList1M.SelectedIndex > 0) && (tbDirectoryMovie.Text.Length == 0))
                {
                    filemov.SaveAs(Server.MapPath("~/App_Uploads_Movies/" + DropDownList1M.SelectedItem.Text + "/" + moviefile), true);

                    Session["catmovie"]   = DropDownList1M.SelectedItem.Text;
                    Session["Filesmovie"] = moviefile;
                }
            }
        }


        getfolders(ref al, Server.MapPath("~/App_Uploads_Movies/"));

        if ((Session["catmovie"] != null) && (Session["Filesmovie"] != null))
        {
            ddCatMovie.SelectedValue = Session["catmovie"].ToString().Replace("\\", "/");
            getfiles(Server.MapPath("~/App_Uploads_Movies/") + ddCatMovie.SelectedValue);
            ddFilesMovie.SelectedValue = Session["Filesmovie"].ToString();
            showmovie(ddCatMovie.SelectedValue, ddFilesMovie.SelectedValue);
        }

        UpdatePanel1Movie.Update();
        UpdatePanel2Movie.Update();
    }