fkeles

Default.aspx

Jan 16th, 2026
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.18 KB | Software | 0 0
  1. <%@ Page Language="C#" AutoEventWireup="true" %>
  2. <%@ Import Namespace="System.IO" %>
  3.  
  4. <script runat="server">
  5.     protected void btnUpload_Click(object sender, EventArgs e)
  6.     {
  7.         if (fileUpload.HasFile)
  8.         {
  9.             try
  10.             {
  11.                 // Map the virtual ~/data folder to a physical path
  12.                 string folderPath = Server.MapPath("~/data");
  13.                
  14.                 // Create the directory if it doesn't exist (Tests FSS Write Permissions)
  15.                 if (!Directory.Exists(folderPath))
  16.                 {
  17.                     Directory.CreateDirectory(folderPath);
  18.                 }
  19.  
  20.                 string fileName = Path.GetFileName(fileUpload.FileName);
  21.                 string fullPath = Path.Combine(folderPath, fileName);
  22.  
  23.                 // Save the file
  24.                 fileUpload.SaveAs(fullPath);
  25.  
  26.                 lblStatus.Text = "Successfully uploaded to: " + fullPath;
  27.                 lblStatus.ForeColor = System.Drawing.Color.Green;
  28.             }
  29.             catch (Exception ex)
  30.             {
  31.                 lblStatus.Text = "Upload Error: " + ex.Message;
  32.                 lblStatus.ForeColor = System.Drawing.Color.Red;
  33.             }
  34.         }
  35.         else
  36.         {
  37.             lblStatus.Text = "Please select a file first.";
  38.             lblStatus.ForeColor = System.Drawing.Color.Orange;
  39.         }
  40.     }
  41. </script>
  42.  
  43. <!DOCTYPE html>
  44. <html>
  45. <head>
  46.     <title>OCI FSS File Upload Test</title>
  47.     <style>
  48.         body { font-family: sans-serif; margin: 40px; line-height: 1.6; }
  49.         .container { border: 1px solid #ccc; padding: 20px; border-radius: 8px; max-width: 500px; }
  50.     </style>
  51. </head>
  52. <body>
  53.     <div class="container">
  54.         <h2>FSS Upload Test</h2>
  55.         <form id="form1" runat="server">
  56.             <p>Select a file to save to the <strong>~/data</strong> folder:</p>
  57.             <asp:FileUpload ID="fileUpload" runat="server" /><br /><br />
  58.             <asp:Button ID="btnUpload" runat="server" Text="Upload File" OnClick="btnUpload_Click" />
  59.             <br /><br />
  60.             <asp:Label ID="lblStatus" runat="server" Text=""></asp:Label>
  61.         </form>
  62.     </div>
  63. </body>
  64. </html>
Advertisement
Add Comment
Please, Sign In to add comment