Write a file upload is not easy.

xiaoxiao2021-04-05  274

Byte [] format_content; // binary array is used to store binary String Beiz = txtBeizhu.Text; //txtFile.postedFile.saveas (); string filenamelen = "pgformatadd.aspx"; // The file name of the current file String localPath = Server.mappath (filenamelen); // Get the physical path of the current file string filepath = localpath.substring (0, localpath.length-filenamelen.length); // Get the physical path of the current directory String filename = ""; // upload File extension string [] strfile = txtFile.Value.split ('.'); Filename = strfile [strfile.length-1]; // Get file extension filepath = "loadFile." Filename; txtfile.postedfile.saveas, TXTFILE.POSTEDFILE.SAVEAS FilePath;

FILESTREAM File = New filestream (filepath, filemode.open; format_content = new byte [file.Length]; file.read (format_content, 0, (int) file.Length); file.close (); pf.insertRecord (Format_name , Format_Type, Format_Content, FileName, Beizhu; Response.write ("Add success! '); window.location.href =' pgformatshow.aspx '; ");

I finally wrote a little.

转载请注明原文地址:https://www.9cbs.com/read-132075.html

New Post(0)