Virtual Directory in IIS and sql server filetables - sql-server

I have an ASP.NET MVC application and which has two virtual directories. The first one (let's name it FirstDir) references some folder on the server (for example C:\SomeDir).
I connect to a MS SQL Server Database. This database has a Filetable named MyFiles. I can explore the directory of table MyFiles in Windows Explorer by path \\sql-server-instance-name\mssqlserver\MyData\MyFiles. It contains files stored in table MyFiles.
The second virtual directory (SecondDir) in my app references MyFiles tabe's directory (\\sql-server-instance-name\mssqlserver\MyData\MyFiles) because I would like to use files stored in this table directly from my ASP.NET application.
Then I write the following markup:
<!--Here I retrieve the image from first virtual dir, i.e. from file system-->
<img src="/SiteName/FirstDir/first.png" />
<!--And here I get the image from second virtual dir, i.e. from FileTable-->
<img src="/SiteName/SecondDir/second.png" />
The image in first img was loaded correctly. But the second image wasn't loaded (error 500.19).
Is it possible to get images from FileTable's directory in browser?
UPDATE:
I can load image from filetable in browser by UNC-path (like this: \\sql-server-instance-name\mssqlserver\MyData\MyFiles\first.png)
but I can not to use this path as src in img-tag (message in browser's console: 'Not allowed to load local resource' )

Related

Uploading files to a domain using form

I have written an application in CakePHP 3.x and there is a form to upload files.
At present, files are being uploaded to WWW_ROOT.'files' which is /app/webroot/files/ path.
To store files separately from core application, I created a subdomain cdn.example.com whose path is like /home/user/example.com/cdn.example.com/.
since, uploading files requires absolute path, how can I get absolute path of the subdomain cdn.example.com same as $_SERVER['DOCUMENT_ROOT']; from example.com?
First check if your server allow to write files from main domain to subdomain.
You can't get the absolute path of a different domain of the one you deployed your application, you should store the path in a variable or in constant.
If you really need to store files in another domain/subdomain and any path is blocked you should consider to reupload the files via FTP script.

How to include external ASP file?

I have a "Main" SQL database - with 20 websites sending / receving data.
All sites Works with Classic ASP.
Today I create an include file to connect all sites to db.
My question is:
Its possible to create only one "conn file" and include this file to all sites?
Why?
because I need to change the connection - and now I need to change 20 files for all sites..
any idea?
Place that file to include in a folder on the server.
Create a virtual directory in each site pointing to that folder.
Add the following to the either the pages that need the connection or a global include file for each site.
<!--#include virtual="/virtualdir/connfilename"-->

Best way to store documents ( pdf , word ...) in a database ( postgres 9.4)

Problem :
To save documents such a pdf file or word...
Approach :
but it seems to me not a good idea to store it directly in the database.
I prefer to store only the address of the file in a column and to save the file itself on a folder beside my database.
Todo :
Is there a trick to create a folder beside the database (mdf ldf) and to store the relativly to the mdf I mean (.. /document) for example?
after read all comments
suppose our website is xyz.com/index.html for Production and
xyz.com/Dev/index.html for Development
under this application we would have one folder /Doc
for production application path would be xyz.com/
and Development application path would be xyz.com/Dev/
we will save the path in DB table colummn is DOC/doc1.pdf etc ...
when we bring the data from DB then we have to write a code on client end
that would be application path + DB path in column
for Production path would be xyz.com/DOC/doc1.pdf and
for Development path would be xyz.com/Dev/DOC/doc1.pdf
so you will get always right path to show your doc on websites

angular file upload and preview

I am using ng-file-upload library to post files to my back end Web Api. Once the file is posted I save it to the following folder
"~/App_Data/Tmp/FileUploads/"
and also save the path to my database.
Now when I go on edit mode; I want to get a preview of all uploaded files (photos). But when I use something like
ng-src="path"
I get
"Not allowed to load local resource"
is this the right approach, when serving files from disk?
That path is a server path and not a client path so for sure that won't work.
You need to have an endpoint on your server to allow downloading those files with id or name/path and then set the src of the img to that url.
The implementation download endpoint depends on your backend technology.
If in your edit mode you still have access to the file object that use has just selected then you can do:
<img ngf-src="file">

Specify path of sqlite database

I'm trying to create a standalone HTML5 document that utilizes SQlite. I want to save the database in the same directory as the html file so that I can access the data on a usb stick from any computer. How do I specify where the database ought to be saved?
This is all I have so far:
var db = window.openDatabase("gtd", "", "GTD 3.0", 1024*1000);
From what I understand, the browser handles how and where the SQLite database is created or read from. Firefox places the SQLite db into a file inside the user's profile folder.
In Firefox the DOM storage data is stored in the webappsstore.sqlite file in the profile folder (there's also chromeappsstore.sqlite file used to store browser's own data, notably for the start page - about:home, but potentially for other internal pages with "about:" URLs).
(from https://developer.mozilla.org/en/DOM/Storage)

Resources