How to Upload File in Asp.net

Here in this example we browse a file from our pc and upload that file to some other location in our pc.

Default.aspx

<input type=file id=File1 name=File1 runat=”server”>
<input type=”submit” id=”Submit1″ value=”Upload” runat=”server” name=”Submit1″>

Defalut.aspx.cs

protected void Submit1_ServerClick(object sender, EventArgs e)
{
if( ( File1.PostedFile != null ) && ( File1.PostedFile.ContentLength > 0 ) )
{
string fn = System.IO.Path.GetFileName(File1.PostedFile.FileName);

//Create Data Folder within the Location u Specified
string SaveLocation = “D:\UploadedFiles” + “\” + fn;

//File will be Uploaded to the Specified Location
try
{
File1.PostedFile.SaveAs(SaveLocation);
Response.Write(“The file has been uploaded.”);
}
catch ( Exception ex )
{
Response.Write(“Error: ” + ex.Message);
}
}
else
{
Response.Write(“Please select a file to upload.”);
}
}

You can give the specified location to upload in SaveLocation string.

Download

CakePHP Files and Folder Structure

When you unpack Cake on your server you will find four folders – app, cake, tmp and vendors. The cake folder is where the core libraries for Cake lay and you generally won’t ever need to touch them unless you want to do some customization to Cake itself.


The app
is where your application specific folders and files will go. The separation between the cake folder with the core libraries and the app folder make it possible for you to have many app folders sharing a single set of Cake libraries. This also makes it easy to update CakePHP: you just download the latest version of Cake and overwrite you current core libraries; No need to worry about overwriting something you wrote for your app.

The tmp directory is used for various Cake operations, such as baking (automatically creating new php files), caching, and logging.

You can use the vendors directory to keep third-party libraries in. You’ll learn more about vendors later.

The folders structure and their basic purposes:

— root (the root directory)

— — app (here’s where your application logic will go)

— — — config (application specific configurations)

— — — controllers (controllers go here)

— — — — components

— — — index.php

— — — models (models go here)

— — — plugins (third party apps – go here)

— — — views (view related files go here)

— — — — elements (small repeated layout items go here)

— — — — errors (error pages go here)

— — — — helpers (your home-based helpers go here)

— — — — layouts (page layouts go here)

— — — — pages (static content managed by PagesController go here)

— — — webroot (this directory as your webroot, and stick your public files in here)

— — — — css

— — — — files

— — — — img

— — — — js

— — cake (this is where the libraries are placed: Note: it’s best not to touch)

— — index.php

— — tmp (used for logs, baking, etc.)

— — vendors (stick your third party libraries here)


How to Embed a Flash File into C# Window Form?

To embed a flash file in C# Windows .Net Application we can use Shockwave Flash Object ActiveX Control.

Follow the Steps to embed flash file:

Step 1: In Tool box right click and select the menu “Choose Items”.

Step 2: From Choose Toolbox Items window select “Com component” tab.

Step 3: Scroll down and make sure “Shockwave Flash Object” is ticked and click ok. The Shockwave Flash Object will now appear in the toolbox.

Step 4: Simply click and drag the Shockwave Flash Object to window Form.

Step 5: Add the Code “Form Load”.

axShockwaveFlash1.LoadMovie(0, Application.StartupPath + “flash.swf”);

These steps embed the flash file and loads “flash.swf” in the application path when window loads.