0

My client uploads MP4s to a folder behind the web root for internal usage. They would like to play these directly for some users from a web page rather than download. Is that even possible?

I can get the list of MP4s via the following, but of course I cannot directly load those as a src in a video tag.

set fs = Server.CreateObject("Scripting.FileSystemObject")
set fo = fs.GetFolder(folderpath)
for each x in fo.files
next

Is it possible to either load that file into a video tag or link to an ASP page that directly outputs MP4 format?

Thanks

RobertyBob
  • 803
  • 1
  • 8
  • 20
  • Quick question .. when you say behind the web root for internal use .. is that the problem? You can't access it ? OR is it that you haven't figured out how to imbed a player into a webpage and point it to that link? If its the first thing, add the virtual directory in IIS pointing to the location, and then you use something like this to point to it. --> – easleyfixed Aug 25 '23 at 15:15
  • What about this -- From here --> https://www.w3schools.com/html/html5_video.asp – easleyfixed Aug 25 '23 at 15:51
  • Keep me posted if either of that get you in the ballpark and I will type up an official answer. Thanks in advance. – easleyfixed Aug 25 '23 at 16:01
  • many thanks - yeah the files are uploaded to a location in the server C drive but not within inetpub or webroot so I can access the file list with the code but when I get the path, it is a local path that doesn't then work in the video tag src. THe video player is fine but the path to the file isn't valid cos not in the webroot. I think the incude virtual might work if I can work out how to handle that – RobertyBob Aug 25 '23 at 16:30
  • Ok, so do you have access to the Internet Information Services (IIS) panel? Find the website in question, and add a virtual directory pointing TO the directory that is outside of the webfolder, and then you can refrence that directory almost as if it was local. – easleyfixed Aug 25 '23 at 16:35
  • I'll have to check on Monday but we definitely have lines at the top of other files that are include virtual...... - ASP is outside my knowledge so need to work out exactly how that works - thanks again – RobertyBob Aug 25 '23 at 16:43
  • Ironcailly, this isn't even an ASP thing, but something to do with the Internet Information Services that is hosting the website. It could be javascript or python, but in any case, the directory that is NOT in the WebRoot must have a virtual directory created so that it can access the path as if it was local. – easleyfixed Aug 25 '23 at 16:55
  • Look under the virtual directory creation but here is how to do it--> https://learn.microsoft.com/en-us/previous-versions/aspnet/zwk103ab(v=vs.100) – easleyfixed Aug 25 '23 at 16:56
  • The best approach is to [create an intermediary page](https://stackoverflow.com/a/35014520/692942) that handles pulling the file from the file system (wherever that may be) and returning it as the raw response using `Response.BinaryWrite()`. – user692942 Aug 25 '23 at 21:55
  • thanks user692942 - trying to use this but don't seem to be able to target the C:\ path for the file so not working. Trying virtual directory again now – RobertyBob Aug 28 '23 at 13:44
  • @RobertyBob that will be a permission issue. Make sure that the application pool user has at least read access to the file. Would suggest testing the script with a location inside the web site first then once that works you can work out what is needed to get it working elsewhere. Remember that the C:\ drive in Windows is usually locked down, so would suggest not storing the files are the root of the C:\ drive but maybe create a folder for them to live in and assign permissions accordingly. – user692942 Aug 30 '23 at 08:13
  • @easleyfixed - we managed to sort this by adding the virtual directory via IIS and then I was informed that we also have access to PHP so wrote a little PHP file to read the video ontent and output - this intermediate file was then loaded as the src for the video. If you add an official response i can mark it as the answer - thanks – RobertyBob Aug 31 '23 at 10:32
  • ty for the update, I shall do it, glad you got it going! – easleyfixed Aug 31 '23 at 13:03

1 Answers1

0

To access the link that is outsite of the main web folder, you need to create a virtual directory that links to the directory hosting the file.

Open Internet Information Services (IIS) and create a virtual directory for the file in question, and then you can treat the folder as if it was locally found inside of the web ablication as far as linking assets.

Linked is a guide explaining how to do this visually. https://computingforgeeks.com/configure-virtual-directory-on-windows-iis-server/?expand_article=1

easleyfixed
  • 219
  • 1
  • 13