473,394 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Displaying image from a directory stored in another drive of server

I have to display image on webpage. Images are stored on some other directory of the webserver not in the project drive and directory.

When I develop it, it is working on developers machine but when i upload it on the server. I run it, it won't show the images.
The code is given below.

Expand|Select|Wrap|Line Numbers
  1. Private Function Showpic() As Integer
  2.  
  3. Dim sDirName As String
  4.  
  5. Dim lst As ArrayList = New ArrayList()
  6.  
  7. Dim html As String
  8.  
  9. sDirName = "\\192.168.4.253\Icon\Image\" & Session("Apid")
  10.  
  11. Dim dDir As New DirectoryInfo(sDirName)
  12.  
  13. If Not dDir.Exists Then
  14.  
  15. msg = "No Document Attached With This Application"
  16.  
  17. Else
  18.  
  19. Dim d As New System.IO.DirectoryInfo(sDirName)
  20.  
  21. Dim intFolders, intFiles As Integer
  22.  
  23. intFolders = d.GetDirectories.GetUpperBound(0) + 1
  24.  
  25. intFiles = d.GetFiles("*.jpg").GetUpperBound(0) + 1
  26.  
  27. Dim s As String
  28.  
  29. For Each s In Directory.GetFiles(sDirName, "*.jpg")
  30.  
  31. html = "<IMG src=" & s & " height=100 width=100>"
  32.  
  33. lst.Add(html)
  34.  
  35. Next
  36.  
  37. DataList1.RepeatColumns = intFiles
  38.  
  39. DataList1.DataSource = lst
  40.  
  41. DataList1.DataBind()
  42.  
  43. End If
  44.  
  45. End Function
Feb 23 '07 #1
3 1344
kenobewan
4,871 Expert 4TB
Have you copied your code from word or some other text editor? Its very hard to read.
Feb 23 '07 #2
vijaydiwakar
579 512MB
I have to display image on webpage. Images are stored on some other directory of the webserver not in the project drive and directory.

When I develop it, it is working on developers machine but when i upload it on the server. I run it, it won't show the images.
The code is given below.

[size=2][color=#0000ff]Private[/color][/size][size=2] [/size][size=2][color=#0000ff]Function[/color][/size][size=2] Showpic() [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]Integer

[/color][/size][size=2][/size][size=2][color=#0000ff]Dim[/color][/size][size=2] sDirName [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]String

[/color][/size][size=2][/size][size=2][color=#0000ff]Dim[/color][/size][size=2] lst [/size][size=2][color=#0000ff]As[/color][/size][size=2] ArrayList = [/size][size=2][color=#0000ff]New[/color][/size][size=2] ArrayList()

[/size][size=2][color=#0000ff]Dim[/color][/size][size=2] html [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]String

[/color][/size][size=2]sDirName = [/size][size=2][color=#800000]"\\192.168.4.253\Icon\Image\"[/color][/size][size=2] & Session([/size][size=2][color=#800000]"Apid"[/color][/size][size=2])

[/size][size=2][color=#0000ff]Dim[/color][/size][size=2] dDir [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]New[/color][/size][size=2] DirectoryInfo(sDirName)

[/size][size=2][color=#0000ff]If[/color][/size][size=2] [/size][size=2][color=#0000ff]Not[/color][/size][size=2] dDir.Exists [/size][size=2][color=#0000ff]Then

[/color][/size][size=2]msg = [/size][size=2][color=#800000]"No Document Attached With This Application"

[/color][/size][size=2][/size][size=2][color=#0000ff]Else

[/color][/size][size=2][/size][size=2][color=#0000ff]Dim[/color][/size][size=2] d [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]New[/color][/size][size=2] System.IO.DirectoryInfo(sDirName)

[/size][size=2][color=#0000ff]Dim[/color][/size][size=2] intFolders, intFiles [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]Integer

[/color][/size][size=2]intFolders = d.GetDirectories.GetUpperBound(0) + 1

intFiles = d.GetFiles([/size][size=2][color=#800000]"*.jpg"[/color][/size][size=2]).GetUpperBound(0) + 1

[/size][size=2][color=#0000ff]Dim[/color][/size][size=2] s [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]String

[/color][/size][size=2][/size][size=2][color=#0000ff]For[/color][/size][size=2] [/size][size=2][color=#0000ff]Each[/color][/size][size=2] s [/size][size=2][color=#0000ff]In[/color][/size][size=2] Directory.GetFiles(sDirName, [/size][size=2][color=#800000]"*.jpg"[/color][/size][size=2])

html = [/size][size=2][color=#800000]"<IMG src="[/color][/size][size=2] & s & [/size][size=2][color=#800000]" height=100 width=100>"

[/color][/size][size=2]lst.Add(html)

[/size][size=2][color=#0000ff]Next

[/color][/size][size=2]DataList1.RepeatColumns = intFiles

DataList1.DataSource = lst

DataList1.DataBind()

[/size][size=2][color=#0000ff]End[/color][/size][size=2] [/size][size=2][color=#0000ff]If

[/color][/size][size=2][/size][size=2][color=#0000ff]End[/color][/size][size=2] [/size][size=2][color=#0000ff]Function[/color][/size]
[size=2][color=#0000ff]
[/color][/size]
dear try to use server.mappath
Feb 23 '07 #3
i have used server.mappath. Still it is not working.
The code is reading no. of image file. but not displaying the images.
Feb 24 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

23
by: Erik Schulp | last post by:
Hi all, I am using a background image via a stylsheet. I've used this code: background-image:url("/images/tile.gif"); (which I think is correct) The image doesn't show up however, the path,...
7
by: Vinay | last post by:
Hi All: I have a small application that stores images either in the database or as files (depending on the user preference). I'm in the process of providing a web interface to this application....
3
by: Christopher Mouton | last post by:
We regularly make drive images of our entire server and store it at a backup site. To be honest I have never fully understood how the imaging programs deal with open files. My question is will the...
5
by: Michael C | last post by:
....on a remote machine? Thanks, Michael C.
4
by: pmud | last post by:
Hi, I have an image which resides on a different server...on data server. I am developing on Development server. When I use the image URLin my ASP.Net web page as ...
35
by: Stan Sainte-Rose | last post by:
Hi, What is the better way to save image into a database ? Just save the path into a field or save the image itself ? I have 20 000 images (~ 10/12 Ko per image ) to save. Stan
3
by: CLEAR-RCIC | last post by:
I have several images i want to display in an ASP.Net application. The images are being passed to me in binary format from another application. Is there a good way to write them directly to an...
8
by: Jon Weston | last post by:
I'm setting up an Access2003 database with pictures. I put a bound ole picture ctrl on a form that's source is the table that contains the pictures and follow ALL the directions for embedding a...
6
by: Jeff | last post by:
hi asp.net 2.0 I have a image (.jpeg) stored in sql server 2005 and now I want to display it on a webpage. So I created a webpage (Image.aspx) which just writes the buffer data to the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...

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.