Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Uploading anImage to a folder specific to username 1

Status
Not open for further replies.

autumnEND

Programmer
Nov 1, 2005
61
GB
Hi, ive been trying to enable users to add images to a folder based on there user.identity.name

so if the user is logged in as TEST
when they add an image it would make a folder inside the images folder called TEST

C:\\images\TEST

also would there be a way to check if the folder was allready created? if it was still uplaod the file into the folder

ive been using this code to add files

If FileUpload1.HasFile Then
Try
FileUpload1.SaveAs("C:\\Files\\" + FileUpload1.FileName)
LblStatus.Text = "File Successfully Uploaded"
Catch
LblStatus.Text = "Unable to save the file"
End Try
Else
LblStatus.Text = "You have to select a file to upload"
End If


also is it possible to set allowable extensions to such as .jpg, .bmp etc?

im new to asp.net , so any help would be greatly appreciated
 
im not sure how to implement the method above
Using TipGiver's example above, you simply need a treeview named trreview1.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
i added a treeview called Treeview1 and added the cose into the aspx.vb page im wanting to display on :

Protected Sub TreeView1_SelectedNodeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TreeView1.SelectedNodeChanged

Dim tn As TreeNode
Dim myimages() As String = IO.Directory.GetFiles(Server.MapPath("images") & "/" & User.Identity.Name)

For i As Integer = 0 To myimages.Length - 1
tn = New TreeNode
tn.ImageUrl = myimages(i)
TreeView1.Nodes.Add(tn)
Next

tn = Nothing

End Sub

but when i view the page it doesnt display any of the images when the user is logged in.

also would it work using a query string
 
No, add the code in a button click event or in page load event. For the second, you will need to know the users name. That way you can use a query string (user.identity.name). Check the .redirect and the .transfer of the page object
 
You've put the code in the SelectedNodeChanged so the image paths will only be loaded then rather than when the page is loaded.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
its working now, the only problem being if the user uplaods a picture with spaces in such as "picture one.jpg", then it wont display , it displays the red cross instead.

i guess id need to rename the images somehow when they are uplaoded.
 
I have no idea what are you talkng about. I do not have such a problem.
 
would it be a problem that i run my application from my computer,its set up as a server.
maybe that causes the problem with the file://d extension
 
is there a way to make it display the link to the image

such as a link like this .... etc

rather than have :

file://d/inetpub/images .... etc

ive been looking for a solution but cant find one anywhere

any pointers would be greatly appreciated
 
Yes, you must know what the virtual path to the file is, so simply use that instead of Server.MapPath.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top