forked from nikunjness/cloudOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload.aspx.cs
90 lines (85 loc) · 3.2 KB
/
upload.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Diagnostics;
using System.IO;
public partial class upload : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
fileview d = new fileview();
string current = d.currentfolder();
if (FileUpload1.HasFile)
{
try
{
string fname = FileUpload1.PostedFile.FileName;
string fpath;
if (!current.EndsWith("/"))
{
fpath = current + "/" + fname;
}
else
{
fpath = current + fname;
}
FileUpload1.PostedFile.SaveAs(fpath);
string[] vdo = { ".mp4", ".wmv", ".rm", ".3gp"};
foreach (string type in vdo)
{
if (type == Path.GetExtension(fpath))
{
string strinp;
strinp = fpath.ToString();
fname = Path.GetFileNameWithoutExtension(fpath);
string prnt = Directory.GetParent(fpath).ToString();
if (!prnt.EndsWith("/") || !prnt.EndsWith("\\"))
prnt = prnt + "\\";
if (prnt.StartsWith("E:/cloudos"))
prnt = prnt.Replace("E:/cloudos", "~");
if (prnt.StartsWith("E:\\cloudos"))
prnt = prnt.Replace("E:\\cloudos", "~");
string strop;
strop = Server.MapPath(prnt + fname + ".flv");
Process proc;
proc = new Process();
string filargs = "-i " + strinp + " -ar 22050 " + strop;
proc.StartInfo.FileName = Server.MapPath("~/Bin/ffmpeg.exe").ToString();
proc.StartInfo.Arguments = filargs;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = false;
proc.StartInfo.RedirectStandardOutput = false;
try
{
proc.Start();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
proc.WaitForExit();
proc.Close();
if (File.Exists(strinp))
File.Delete(strinp);
}
}
}
catch (Exception ex)
{
Response.Write("Unable to upload file.Try Again.");
}
}
}
}