Image uploaded example

zhaozj2021-02-16  74

.CS

Private int uploadPic () {if (myfile.postedfile! = null) {Try {string filedir = "c: // ibrary // PagePic //"; // Note You can change to the directory you want to upload String FileName = System.IO.Path.GetFileName (myFile.PostedFile.FileName); string filePath = System.IO.Path.Combine (fileDir, fileName); LfikePath.Text = filePath; myFile.PostedFile.SaveAs (filePath);} catch ( Exception EXC) {this.alertBox; return -1;}}

Return 0;}

Private void bsubmit_click (Object sender, system.eventargs e) {if (uploadPic () == - 1) {return;}}

.aspx

<< Input id = "myfile" type = "file" οnchange = "document.all.ifytp.src = this.Value" runat = "server" >> << asp: image id = "iftp" runat = "server" Width = "72px" >> << / asp: image >>

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

New Post(0)