Lunarpages Web Hosting Forum

Author Topic: How to upload file?  (Read 22812 times)

Offline Lucky:)

  • Space Explorer
  • ***
  • Posts: 7
How to upload file?
« on: January 26, 2011, 11:07:52 PM »
I need an advise how to upload image file into website directory.

I'm trying

Code: [Select]
and getting error: Access is denied.


Offline almedajohnson

  • Trekkie
  • **
  • Posts: 13
    • Hire Joomla Developer
Re: How to upload file?
« Reply #1 on: February 06, 2011, 08:37:16 PM »
Try this code:

The fileupload.aspx code is:

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="" >

<head runat="server">

 <title>File Upload Demostration</title>



    <form id="Form1" method="post" runat="server">

     <table cellpadding="0" cellspacing="0" width="80%" align="center" border="4">

      <tr><td height="20px"></td></tr>

       <tr><td height="200px" align="center" valign="middle">

               <input id="MyFile"   type="file" size="81" name="File1" runat="server" />

                      <br /><br />

                             <asp:Button id="btnSubmit"   runat="server" Text="Submit" Width="139px" Height="30px" OnClick="btnSubmit_Click"></asp:Button>

                             <asp:Label id="lbl"   runat="server" Width="402px" Height="33px"></asp:Label>






The fileupload.aspx.cs is:

using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;


public partial class _Default : System.Web.UI.Page


    protected void Page_Load(object sender, EventArgs e)




    protected void btnSubmit_Click(object sender, EventArgs e)



        if (MyFile.PostedFile.ContentLength == 0)


            lbl.Text = "Cannot upload zero length file";



        lbl.Text = MyFile.PostedFile.FileName;





Offline Lucky:)

  • Space Explorer
  • ***
  • Posts: 7
Re: How to upload file?
« Reply #2 on: March 07, 2011, 09:47:11 PM »
Thanks. almedajohnson.

Offline stevnparkr

  • Newbie
  • *
  • Posts: 1
Re: How to upload file?
« Reply #3 on: December 21, 2018, 05:51:25 AM »
All files and folders should go to the public_html directory if you are on a Linux server. The public_html folder can be accessed either by FTP or via FileManager in cPanel and LPCP.

On a Windows server, you upload them under the httpdocs folder.

To access your account via FTP, connect to (replace with your actual domain name) or to,,, or (replace server with the server your account is on and the server domain depends on the server you are on. This can be found in the Critical Account Information email)

Please see our article on FTP Basics.

Be sure to create an index file for your first page. This can be index.htm, index.html, index.php, etc.

Please note: our Linux servers are case sensitive so index.htm and Index.htm are two separate files. Index.htm will not be recognized as the default first page. It must be index.htm (.html, .php, etc.) in lowercase.