|
The FileUpload control has a SaveAs(string path) method. You can use that method to save the file to any path using any filename you want. Just make sure ASP.NET has permissions to write to that path. So, you can do something like this to save the uploaded file to the uploads folder in the root of your website:
fileUpload1.SaveAs(Server.MapPath("~/uploads/")
+ System.IO.Path.GetFilename(fileUpload1.FileName));
|
|
|
|
|
thank u for ur reply
i've tried that, still at my database i get only the file's name without the path ~/folder/...
i need to add it as a string before the file's name.
or! if there was a way for inserting like an auto text option to that column each time i insert the data (before the file name).
any idea how?
thanks
|
|
|
|
|
Do not post to multiple forum
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
im sorry actually i disabled the code lol
now im running this code ugave me and im getting some errors.
System.IO.Path' does not contain a definition for 'GetFilename'
The name 'fileUpload1' does not exist in the current context
|
|
|
|
|
Hi there,
the ID of your upload Control is "FileUpload1" in your example, not "fileUpload1". Always pay attention to the letter case. Same with GetFilename. The Method is written "GetFileName".
What the upload control does, is the following: it saves your
selected file to the file-system. No path-saving to your database at this point. Where
are you saving the path to your db? there you have to save the virtual path of your upload
folder in addition to your filename. Just concat the strings there.
Good Luck
|
|
|
|
|
Hi michaelschmitt,
thank you for ur reply and for ur information
the letters are actualy as they should be.
____
I still cannot get it fixed even after adding the System.IO.Path..
//
FileUpload1.PostedFile.SaveAs(Server.MapPath(("~/photo/" + System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName))));
//
|
|
|
|
|
What i was trying to say is that your posted code does not include any interaction with
your access database. It just takes the selected filename from your upload control and saves this
file to the desired folder. This code alone would not insert the filename into your access-database table.
To clarify:
"~/photo/" is the virtual path of your upload folder. Server.MapPath is needed to tranform this to the corresponding
physical directory on your web-server (e.g.: c:\http\mysite\photo). FileUpload1.SaveAs(...) saves your file to this folder.
Use
string virtualFilePath = "~/photo/" + FileUpload1.FileName;
to get your desired Path und save it to your database.
modified on Monday, March 29, 2010 9:43 AM
|
|
|
|
|
i want to fetch time and date information separately from a datetime type field of a table created using sql 2005 of asp.net...i wasn't able to understand the pages displayed on google for the same query...??
|
|
|
|
|
Not sure if I understood your question correctly.
You can use the convert method and pass in the style. You can get the date by using styles 101 to 107 and 108 or 114 to get the time part.
This MSDN article[^] provides you with the syntax and shows the output for the various styles.
Tarakeshwar Reddy
There are two kinds of people, those who do the work and those who take the credit. Try to be in the first group; there is less competition there. - Indira Gandhi
|
|
|
|
|
i've used a gridview datasource control to display the schedule ....thr in i've specified the time field as datetime datatype in the table....nw when i'm displaying the page along with time, date is also being displayed...i don want to display the date....but only time....can you help me...???
|
|
|
|
|
You can use a bound field and set the DataFormatString.
<asp:BoundField HtmlEncode="False" DataField="Time" DataFormatString = "{0:T}" HeaderText="Time">
Take a look at the Standard DateTime Format Strings [^] and this article[^] which shows you how to create a bound field.
Tarakeshwar Reddy
There are two kinds of people, those who do the work and those who take the credit. Try to be in the first group; there is less competition there. - Indira Gandhi
|
|
|
|
|
|
See responses to below.
You should stop and do some research on your own. These are not difficult problems to solve and there are plenty of resources available.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Am doing aE-greetings project . so i need to send mail with some text and url of the greeting cards (which is selected by the user) . so pls help me and i have to send automatic email for reminders . please let me also know the technique behind this also. pls
|
|
|
|
|
What part of this are you having difficulties with? What research have you done? What have you tried?
We are not here to do the work for you. If you are having difficulties with a particular part, then ask, but you should first at least try something yourself.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
|
You question not clear.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
string path = MapPath("~/cards/");
string full = path + Session["file"] + "/";
string[] s = Directory.GetFiles(full);
foreach (string str in s)
{
string f = Path.GetFileName(str);
ImageButton im = new ImageButton();
im.Width = 150;
im.Height = 150;
im.ImageUrl = "~/cards/" + Session["file"] + "/" + f;
Session["selected"] = im.ImageUrl;
im.Click += new ImageClickEventHandler(im_Click);
PlaceHolder1.Controls.Add(im);
EnsureChildControls();
}
}
protected void im_Click(object sender,ImageClickEventArgs f)
{
Response.Redirect("editor.aspx");
}
|
|
|
|
|
this is the cod . it only displys the last imagebutton's image
|
|
|
|
|
Hi all,
Is any web monitoring tool by which if any type of problem is ocurring in my web server then an alert
mail we can find.by which we can save that problem and my web server will run without any problem.
If you know about monitoring tool then tell me ...
Thnks..
|
|
|
|
|
if you want to monitor only (without mail alert) there is an in-built utility in windows which you can find inside Control Panel --> Administrative tools -->Performance. There are different parameters mentioned and you can choose any combination and monitor server performance as per your need. It allows you to keep it running and recodring it into a log file so that you can monitor it even at your convenience time.
If you are looking for some mail kind of alert as a part of monitoring, I hope some other fellow aroud here might help you.
Thanks,
Arindam D Tewary
|
|
|
|
|
Thnks to Reply,
but I am looking for some mail kind of alert as a part of monitoring
of my webserver.
if you know any of the third party tool for monitoring it.
then tell me plese.
eathier it is paid or unpaid doesn't matter
Thanks.
|
|
|
|
|
hi sir
please help me
my problem is that if once a user is logged in then there should not be visible login page again after entring url.
i mean suppose i have entered gmail.com in ie and login then if i again open gmail.com in new ie then login page is not there.while inbox page is open.i also want the same for my application.and on login page load i have done this.
if (Session["customer"].ToString() == "Admin")
{
Response.Redirect("Admin/AdminHome.aspx");
}
and i am giving my value to Session["customer"] on login click button from txtuserid.so that's why it gives me error.object reference not set to an instance of an object.
please suggest me another suitable way to solve this issue.
modified on Saturday, March 27, 2010 5:02 AM
|
|
|
|
|
To remove "object reference not set to an instance of an object" error, you should check whether the session object is null before accessing Session["customer"] object.
Thanks,
Arindam D Tewary
|
|
|
|
|
try at the Page_load , first thing in ur page
if (Session["customer"] == null) { Response.Redirect("URLOGINPAGE.aspx"); }
this way, if the user still didnt logout, he will still have access to those secured pages without entering the login page again. till he logout
|
|
|
|