Till now I have been storing my uploaded files in upload folder under the website folder. But now the Drive on which the site is stored is full. How do I store new files on another drive and how should I enter the Filepath in DB?
What I do.
Have a domain (eg. domain.com) point to a website folder
Upload files in upload folder under website folder
Store file path in DB as (/upload/filename)
retrieve file with base URL (www.domain.com/upload/filename)
Now if I store files on another drive how do I enter filepath in DB which would return me the file without affecting URL request.
Create a HTTP handler. There is no reason why the URL needs to be related to any physical location or resource.
Related
I need to print images on ASP.NET site for each order.
Part of the images hosted on external server(cloud) and other part hosted on the same server.
There is a big folder of orders and each order has its own folder inside that big folder.
/Orders/Order_id/
When user load the page i have 2 options, to check if images exists and can be loaded:
By saving in sql table url to each path of file, And if url exists then i can just call it.
-This will make my db tables to save huge amount of url strings.
Or, I can avoid saving anything in db, and every page load to go and check if files exist in folder.
What will be the fastest loading time and minimal resources(cpu and ram) consumption solution to use sql urls and save all that urls or each page load to check if files exist on folder?
i want to get the full path of the uploaded file in the IIS Server without saving the file in the disk by calling File.SaveAs() method. why i want to do this?. Once i have the full path of the file without saving it in the disk i want to upload this file in azure blob container.
I have successfully uploaded the file in azure blob container after saving the file in the disk but i don't want to first save and then delete the file from disk after uploading the file to azure blob container.
Files posted to the server are stored in streams, not in temporary directories. Assuming your object is of type HttpPostedFileBase, you would need to access the InputStream property and read the bytes into your Azure Blob.
I'm uploading files over to a web server via a web service from my local directory. The problem I have is when I have files with the same name but from different directories. For example, I have two files:
Debug\Controls.Resources.dll
Release\Controls.Resources.dll
When the first file gets uploaded, I get a file already exists error when the second file is being uploaded.
What I want to do is include the folder information from which a file belongs to such that when it finds the file with the same name, it will create a folder.
How do I upload the files such that I can include the folder information when it gets to the server? I'm thinking of creating a data structure and upload that object instead of the file.
public class FileUpload
{
private string ContainingFolder {get;set}
private File UploadFile {get;set;}
}
PS: I've already tried zipping the files but for some reason I don't want to go that way.
I am Currently working on asp.net i have worked on file upload by uploading files but i want browse a folder not a file and get all files in it and get foldername and create foldername in server and upload files it to server.Pls give me some refernce and help me to do this.
My aim is when i browse that folder all it files present in it should upload .Only files should upload not folder
Note:To browse folder not file.
Actually you are supposed to include a question if you want an answer, but it seems you are completely new to this so here are a few things you should know when it comes to asp.net and folder/file handling:
Your virtual path always corresponds to a local path on your webserver. Since it would be bad to hardcode that you might want to start off by mapping it. (e.g. /uploads/ to _C:\intepub\application\uploads)
"and get foldername"
string localpath = Server.MapPath("/uploads");
"and create foldername in server"
next you can check if that folder already exists, or if not - create it.
if(!System.IO.Directory.Exists(localpath))
System.IO.Directory.Create(localpath))
Keep in Mind though that your IIS-User needs the rights to create new directories
Now that you have made sure that your upload directory exists, you can upload/download files. Here is a good tutorial to get started:
"and upload files it to server"
http://msdn.microsoft.com/en-us/library/aa479405.aspx
"but i want browse a folder not a file and get all files in"
You can do that on the server, not the client. Your asp.net code never executes on the client.
string[] filenames = System.IO.Directory.GetFiles(localpath);
"My aim is when i browse that folder all it files present in it should upload"
That one isn't so easy, sorry. It would pose a serious security risk to users.
Maybe this will point you in the right direction (apparently it works with Chrome)
How do I use Google Chrome 11's Upload Folder feature in my own code?
When it comes to files, directories, filepaths, etc. in general, I would recommend taking a closer look at these classes:
System.IO.File
System.IO.Directory
System.IO.Path
My client has configured a SFTP server and monitoring the folder using FileWatcher. As soon s as the file are copied to SFTP server, client picks them.
If the connection is broke down while transferring the file, client picks the invalid file.
In between, I go for deleting the invalid file, client has already picked and delete that file from that folder.
How I can stop access for client to that file until I finish the full transaction.
There exist two generic options - upload the file to different folder and move it (you have denied this for your particular case) and upload the file with different name and rename the file once upload is complete.
If you control the server's architecture, you can do the following trick: upload the file with the name of filename..ext . The server will check the file name and know expected size. Once the file is of specified size, it can be picked and renamed by the server.
You should use a temporary folder for upload, and move the files in the monitored folder only when the file is completely upload.