473,725 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem in uploading

hi every body
when i run this code i receive this error! my "wwwroot" folder is
shared, but i don't know what it's reason is!!!
{"Access to the path
\"D:\\Inetpub\\ wwwroot\\irania n\\images\\user _imgs\\Untitled-1.jpg\" is
denied." }

is there a way that the url be relative???

my code is:

public void btnupload_Serve rClick(object sender, System.EventArg s e)
{
string uploadFolder =
"D:\\Inetpub\\w wwroot\\iranian \\images\\user_ imgs\\" ;
if (!(filename.Pos tedFile.FileNam e == "")){
filename.Value. Insert(0,filena me.PostedFile.F ileName.ToStrin g()) ;
}
System.IO.FileI nfo objfile;
objfile= new System.IO.FileI nfo(filename.Va lue);
if (!objfile.Exist s){
HttpContext.Cur rent.Response.W rite("<script
language=javasc ript>alert('! فایل انتخابی وجود
ندارد');</script>");
}else{

string sPath = uploadFolder;
string fname = filename.Value;
int pos;
string extension;

pos = fname.LastIndex Of(".");
extension = (fname.Substrin g(pos + 1)).ToLower();
if (!( extension == "jpg" ) | (pos == -1)){
HttpContext.Cur rent.Response.W rite("<script
language=javasc ript>alert('!(* .jpg ) نوع فایل انتخابی
معتبر نمی باشد');</script>");
}else{
int inroot;
inroot =
fname.IndexOf(" D:\\Inetpub\\ww wroot\\iranian\ \images\\user_i mgs\\", 0);
//build file info for display

pos = fname.LastIndex Of("\\");
fname = fname.Substring (pos + 1);
sPath += fname;
try
{
if (filename.Poste dFile != null)
{
filename.Posted File.SaveAs(sPa th);
Application.Add ("fname", sPath);
}
}
catch(System.Ex ception exc)
{
HttpContext.Cur rent.Response.W rite("<script
language=javasc ript>alert('! مشکلی در جایگزین
تصویر وجود دارد');</script>");
}


}
}

}

Jul 15 '06 #1
1 1417
First, I would check to make sure that the proper account (usually 'ASPNET')
has write access to the desired directory. Also, it looks like you are
making things much more complicated for yourself than necessary. Here is
some simple code that uploads a file:
'fileUpload is a System.Web.UI.H tmlControls.Htm lInputFile

If fileUpload.Valu e.Trim() <"" AndAlso fileUpload.Post edFile.ContentL ength
0 Then
fileUpload.Post edFile.SaveAs(S erver.MapPath(" ./") &
IO.Path.GetFile Name(fileUpload .PostedFile.Fil eName))

End If

Here is an explanation of the code:
The If statement tests to make sure something was entered in fileUpload and
that the file actually has some content. The SaveAs method is used to save
the file to the server. The parameter is the full path of where you want it
saved. You will notice that I generated this string by concatenating the
directory and filename. To get the full path I used the Server.MapPath
method which takes a relative path/directory (in my example I use ./ which
is the current directory) and returns the full path/directory. To get the
filename, I used the GetFileName method which takes a path as a parameter
and returns just the filename (in my example I simply pass it the FileName
property of the PostedFile. If you have any questions about this (or if I
entirely misunderstood your problem), feel free to let me know. Good Luck!
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

<fa*****@yahoo. comwrote in message
news:11******** *************@b 28g2000cwb.goog legroups.com...
hi every body
when i run this code i receive this error! my "wwwroot" folder is
shared, but i don't know what it's reason is!!!
{"Access to the path
\"D:\\Inetpub\\ wwwroot\\irania n\\images\\user _imgs\\Untitled-1.jpg\" is
denied." }

is there a way that the url be relative???

my code is:

public void btnupload_Serve rClick(object sender, System.EventArg s e)
{
string uploadFolder =
"D:\\Inetpub\\w wwroot\\iranian \\images\\user_ imgs\\" ;
if (!(filename.Pos tedFile.FileNam e == "")){
filename.Value. Insert(0,filena me.PostedFile.F ileName.ToStrin g()) ;
}
System.IO.FileI nfo objfile;
objfile= new System.IO.FileI nfo(filename.Va lue);
if (!objfile.Exist s){
HttpContext.Cur rent.Response.W rite("<script
language=javasc ript>alert('! ???? ??????? ????
?????');</script>");
}else{

string sPath = uploadFolder;
string fname = filename.Value;
int pos;
string extension;

pos = fname.LastIndex Of(".");
extension = (fname.Substrin g(pos + 1)).ToLower();
if (!( extension == "jpg" ) | (pos == -1)){
HttpContext.Cur rent.Response.W rite("<script
language=javasc ript>alert('!(* .jpg ) ??? ???? ???????
????? ??? ????');</script>");
}else{
int inroot;
inroot =
fname.IndexOf(" D:\\Inetpub\\ww wroot\\iranian\ \images\\user_i mgs\\", 0);
//build file info for display

pos = fname.LastIndex Of("\\");
fname = fname.Substring (pos + 1);
sPath += fname;
try
{
if (filename.Poste dFile != null)
{
filename.Posted File.SaveAs(sPa th);
Application.Add ("fname", sPath);
}
}
catch(System.Ex ception exc)
{
HttpContext.Cur rent.Response.W rite("<script
language=javasc ript>alert('! ????? ?? ????????
????? ???? ????');</script>");
}
}
}

}
Jul 17 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1867
by: Mike | last post by:
Hi i have a problem in asp.ne i am uploading file to the server using htmlinput controls and every thing is o but i try to upload larger file to the server like more than 4 mb and about 10mb i got server connection lost and time out some no responce is there any solution to that problem using asp.net and c thank
1
2204
by: Jonathan | last post by:
Hi everyone, I have a problem with the file uploading in Asp.Net and I have read a lot on forums on this but never found an answer. Here is the problem: I know Asp.Net maximum Length for uploading a file to the server is 4Mo but I changed that maximum to about 10Mo in my web.config file : <httpRuntime executionTimeout="45" maxRequestLength="10000" useFullyQualifiedRedirectUrl="true" />
4
2153
by: Himanshu | last post by:
hi, Can anybody tell me that thru asp.net using c#, how can we upload and download physical files in any table of SQL Server Database. the uploading part is running successfully but the problem arises in the retriving part of the code. i am not getting that how will i able to download the file which is there in the SQL Server database in the field type "image".
7
5224
by: Ankit Aneja | last post by:
I put the code for url rewrite in my Application_BeginRequest on global.ascx some .aspx pages are in root ,some in folder named admin and some in folder named user aspx pages which are in user folder are using this code of url rewrite project is running completely fine on localhost but after uploading first page (http://emailware.net.temporary.domain.name/user/index.aspx) is fine but as i click 123 Easy-CD Ripper
4
1649
by: Ramakrishnan Nagarajan | last post by:
Hi, I am facing a different problem in my application. In that I am uploading a folder that contain only images. Everything was done and was working fine too. When I executed the application using the localhost it works fine. But when my machine acts as a client and executes the application from another machine (considered as the server) it is telling that the folder is not found, even if the folder is present in the client machine. The...
3
2362
by: Carlos | last post by:
Hello Forum, I would appreciate it if you could recommend settings to use auto-vacuum in my version 7.4 database. I am uploading several thousands records in the database at a rate of ~1 second per record (the data is uploading from a different server). I have noticed that the performance of the uploading is improved if I vacuum the database every so often so I decided to take advantage of auto-vacuuming to maintain the best...
0
1174
by: Ramakrishnan Nagarajan | last post by:
Hi, I am facing a problem in uploading Excel data to the Database. While uploading my code reads Excel Data using OleDbReader and store into a dataset by looping through the OleDbReader result set. The problem is, if I give the date as mm/dd/yyyy format it accepts, but when I give the date in dd/mm/yyyy format, upto 8 rows of data it is reporting the date as invalid. After 8th row even if the date is there (dd/mm/yyyy format), it is...
7
2669
by: jambroo | last post by:
Hello, We are currently having issues uploading files using PHP. It seems files below 8MB are uploaded fine, however files above 8.2MB cause the page to timeout or show a 'Cannot find server or DNS Error' error. I have looked around and read about common problems people have uploading and the solutions they have used have not seemed to help. For this particular page i have increased post_max_size,
3
1913
ganesanji
by: ganesanji | last post by:
hi all, I have written a php coding for uploading a file to a specific folder or location in server which is a Linux server. I think the coding for file uploaing is correct. But it does not work properly. That means the file is not uploaded to the specified location. It always executes the "else" condition in my coding. I think the problem is lieing in the specifed path which is the target path for file uploading. I could not find out...
2
2218
by: Bremanand | last post by:
Hi folks, i am working in C# , i have problem while uploading the file to FTP which has size around 4MB. The code which comes after the bold area is not executed.. here am interacting with DB for every succeessful upload. But its working well for the file which has small size around 1MB. Please give me a solution asap... My code is as follows. string ftpServerIP = rowClient.ToString(); string ftpUserID =...
0
8752
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9401
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9176
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9113
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8097
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.