Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@ Page Language="C#" AutoEventWireup="true" %>
- <%@ Import Namespace="System.IO" %>
- <script runat="server">
- protected void btnUpload_Click(object sender, EventArgs e)
- {
- if (fileUpload.HasFile)
- {
- try
- {
- // Map the virtual ~/data folder to a physical path
- string folderPath = Server.MapPath("~/data");
- // Create the directory if it doesn't exist (Tests FSS Write Permissions)
- if (!Directory.Exists(folderPath))
- {
- Directory.CreateDirectory(folderPath);
- }
- string fileName = Path.GetFileName(fileUpload.FileName);
- string fullPath = Path.Combine(folderPath, fileName);
- // Save the file
- fileUpload.SaveAs(fullPath);
- lblStatus.Text = "Successfully uploaded to: " + fullPath;
- lblStatus.ForeColor = System.Drawing.Color.Green;
- }
- catch (Exception ex)
- {
- lblStatus.Text = "Upload Error: " + ex.Message;
- lblStatus.ForeColor = System.Drawing.Color.Red;
- }
- }
- else
- {
- lblStatus.Text = "Please select a file first.";
- lblStatus.ForeColor = System.Drawing.Color.Orange;
- }
- }
- </script>
- <!DOCTYPE html>
- <html>
- <head>
- <title>OCI FSS File Upload Test</title>
- <style>
- body { font-family: sans-serif; margin: 40px; line-height: 1.6; }
- .container { border: 1px solid #ccc; padding: 20px; border-radius: 8px; max-width: 500px; }
- </style>
- </head>
- <body>
- <div class="container">
- <h2>FSS Upload Test</h2>
- <form id="form1" runat="server">
- <p>Select a file to save to the <strong>~/data</strong> folder:</p>
- <asp:FileUpload ID="fileUpload" runat="server" /><br /><br />
- <asp:Button ID="btnUpload" runat="server" Text="Upload File" OnClick="btnUpload_Click" />
- <br /><br />
- <asp:Label ID="lblStatus" runat="server" Text=""></asp:Label>
- </form>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment