944,144 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Marked Solved
  • Views: 1762
  • ASP.NET RSS
Nov 10th, 2009
0

Change File name while uploading

Expand Post »
Hi..

I want to upload a file with help of FileUpload control, in which, i want to save the file with a specific name or say a name entered in a textbox on a same page.
for ex, if textbox contains "ABC" then the files should be uploaded with abc.jpg name.

how can i restrict user to select only specific types of file in a fileupload control?

also, how can i save an image in 3 different sizes at time of uploading?

when user selects an image, it should be saved in some specific size in a specified folder with the name as in textbox,,,

Thanks,
Similar Threads
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
love_dude1984 is offline Offline
92 posts
since Aug 2008
Nov 10th, 2009
0
Re: Change File name while uploading
In which language you feel comfort please reply with same post
Reputation Points: 10
Solved Threads: 4
Junior Poster in Training
manishmannan is offline Offline
58 posts
since Nov 2009
Nov 10th, 2009
0
Re: Change File name while uploading
hi.

I want the code in c#.net...i hav got the way to save the file with whtever name i want. i just want to know ho to store images in different size and how to use filter in fileupload control..

Thanks.
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
love_dude1984 is offline Offline
92 posts
since Aug 2008
Nov 11th, 2009
0
Re: Change File name while uploading
hii dude
you could upload a file in a folder by a random name and and the name should be store in the data base with their path
and whenever you need image you can call database path
and you got your image
thats it
Reputation Points: 10
Solved Threads: 4
Junior Poster in Training
manishmannan is offline Offline
58 posts
since Nov 2009
Nov 12th, 2009
0
Re: Change File name while uploading
Hey thanks..but instead of going for database, we can directly change its name in SaveAs() itself.

The only problem left is, how can i control filtering of file upload control. Is there any possible way to achieve it?
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
love_dude1984 is offline Offline
92 posts
since Aug 2008
Nov 12th, 2009
0
Re: Change File name while uploading
can you paste your code here !
Reputation Points: 10
Solved Threads: 4
Junior Poster in Training
manishmannan is offline Offline
58 posts
since Nov 2009
Nov 12th, 2009
0
Re: Change File name while uploading
Use this in your event handler for clicking an upload button.

ASP.NET Syntax (Toggle Plain Text)
  1. if (FileUpLoad1.HasFile)
  2. {
  3. String fileName = "yourfilename";
  4. FileUpload1.PostedFile.SaveAs(Server.MapPath("yourpath/") + fileName);
  5. }
Reputation Points: 10
Solved Threads: 2
Newbie Poster
shibbard is offline Offline
17 posts
since Nov 2009
Nov 13th, 2009
0
Re: Change File name while uploading
yeah..thanks..it works fine...

The only problem left is, how to filter the upload control. its possible by coding, like checking the posted file's extension, but is it anyway possible to provide facility in the upload control itself?

do reply..thanks...
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
love_dude1984 is offline Offline
92 posts
since Aug 2008
Nov 13th, 2009
0
Re: Change File name while uploading
try this
ASP.NET Syntax (Toggle Plain Text)
  1. if (fuResume.HasFile)
  2. {
  3. string ext = System.IO.Path.GetExtension(fuResume.PostedFile.FileName);
  4. if (ext == ".doc" || ext == ".txt" || ext == ".rtf" || ext == ".pdf")
  5. {
  6. //do something here
  7. }
  8. }
Reputation Points: 11
Solved Threads: 11
Junior Poster in Training
srikanthkadem is offline Offline
68 posts
since Mar 2008
Nov 13th, 2009
0
Re: Change File name while uploading
Yeah..That works fine...

Thanks..
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
love_dude1984 is offline Offline
92 posts
since Aug 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Anybody Aware of Adobe Flex
Next Thread in ASP.NET Forum Timeline: Calculation Event in C#?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC