I am having a application that uploads files according to the user input..i just want to move that particular file to moved to another folder..
Now i am able to move the files to the destination folder..but it moves all the files which is already there in the folder..
i am creating a folder dynamically while uploading the files..and i need that file to be moved to that created folder...
I need to move only the uploaded file during run time...
E:\Export Documents - Copy\Uploads this path to C:\inetpub\wwwroot
this is my code
Set oFS = Server.CreateObject("Scripting.FileSystemObject")
strDir = "c:\inetpub\wwwroot\" & fldr
oFS.CopyFile "E:\Export Documents - Copy\Uploads\*.jpg", "c:\inetpub\wwwroot\" & fldr
What you probably want to do is identify the file you have just uploaded and then move that. If you are already creating a folder to store the files in in inetpub, you might as well do the same in Uploads, and then just move that folder.
You will probably find it helpful to use fileSystemObject.MoveFolder instead of .CopyFile so that your Uploads folder does not fill up.
If you want some help with how to do that, post the code you are using to upload your file.
For working with the FileSystemObject, this is a useful reference
On another note, is it really wise to move files from Uploads into wwwroot? A malicious user could do some damage in there.
Related
I need to store pdf files that will keep increasing with time on a folder for my app. But I'm not sure which method is consider 'good practice' between if I should store it in a folder within the project architecture (i.e. inside Content folder) or in a folder outside the app. I tried searching online but most people just mention 'File System' and don't give examples on where do they store it.
So my question is, when people mention storing files on the File System, do they usually mean storing it in a folder inside the app (like Content folder) or do they mean storing it in a folder outside the app?
For example: let's say my apps folders/files are within the container folder: /Container/AppFolder/. Should I store the pdf files on the apps Content folder (i.e. /Container/AppFolder/Content) or should I create a new folder OUTSIDE the apps folders to hold these pdf files? (i.e. /Container/PDFFiles, so basically two folders within the container folder - one folder for the pdf files and the other folder for the app)? Which one is consider a good practice? I have considered just putting these files on the Content folder but as the amount of files keep increasing I'm not sure if is bad practice.
Thanks in advance.
You can put it where ever you want on the server, the program will just need proper permissions to that location (I use the IO namespace). However you should put thought into how to organize the files and folders. Is each file to be tied to a specific ID or just all in 1 folder? Think of things you'll need to handle like invalid file names (special characters), duplicate file names etc. Is the location strictly 1 way (upload only)? Or are you enabling download functionality? If you have download functionality stress security, probably creating a download.aspx page specifically for handling download requests and authentication.
I am working on a solution which has two projects in it. One is a virtual app which works in another. The first application is the panel and the second is the website. First application can be accessed with "localhost:10001/panel" and the second with "localhost:10001". You see, I created a virtual path for the first app to work under the second one in Visual Studio and they work great that way.
The problem I am having now is about the file uplaod system, "Blueimp's jQuery-File-Upload" plugin and as backend using "Backload". I must say that these work great on a standalone project. That's why I decided to continue the project using these.
But when it comes to a setup which I explained below, I cannot access the files I upload. I installed fileupload system in the panel project, which is accessed as "localhost:10001/panel" so when I leave the default web.config configuration for backload (default is "~/files"), all files are uploaded to the "localhost:10001/panel/files" path. And after the upload when I refresh the page, all uploaded file links are referencing "localhost:10001/files/" without the "panel" folder.
In BackLoad web.config notes how to change and use root upload folders are explained like that
filesRoot: // Root upload folder. If the value starts with '~/' (e.g. ~/files) the path is relative to the web root, otherwise set an absolute local path (e.g. d:/files) [Default: "~/Files"].
I understand that having "~/" at the beggining of a folder reference shows the project's root. But I can't figure out how to reference the upload folder, instead of the default "~/files", to upload and access all files from the second project's root. When I need to reference folder between these two projects I simple use "../", or "/" to access the second project's (site) root. But doing that in "filesRoot" attribute of BackLoad config settings, all file references are starting "///file....." and shows a local path in the computer.
I simply want to upload and access the files from the "localhost:10001/files" location when I upload files from the panel. Now, I cannot even use the "localhost:10001/panel/files" path because files are uploaded to "panel/files" folder, but are accessed from "files" folder with default settings.
BTW: I am using BackLoad's WebForms Example on this project, and this is a Web Forms project.
I ended up using Files folder as a temp folder. At the time of submit, I move the file which is uploaded in Files folder, to the folder of my need. And the problem is solved.
Thanks anyway...
Salvete! When we set up the asp.net file-uploading control called "NeatUpload", it saves its files to a temporary location, either "YOUR_APP_ROOT /app_data/NeatUpload_Temp/", if the directory is writable, or to the system's temp folder. However, the demo does not seem to actually upload any files, nor does it include an example for saving the files to a particular directory.
How do we save the file we have uploaded and move the uploaded file to a particular folder? My only clue from the documentation is that it has to do with UploadStorageProvider, but I need some help to implement this.
if you read the documentation 3.3 point 6 :
In your codebehind file, process the uploaded file. If you are using
the InputFile control, the uploaded file's client-specified name, MIME
type, and contents can be accessed via inputFileId.FileName,
inputFileId.ContentType, and inputFileId .FileContent, respectively.
If you want to keep the uploaded file, you must use the
inputFileId.MoveTo()method to move the uploaded file to a permanent
location. If you do not, NeatUpload will automatically remove the
uploaded file at the end of the requestto ensure that unwanted files
do not fill up the filesystem. The following code will put the
uploaded file in the application's root directory (assuming sufficient
permissions):
and so on. I hope this is what you are after.
I have a folder that stores images and the paths to the images are stored in the database. There are almost 2500+ employee images stored there.
If I want to change the physical location of the folder that has the images, how do I manage the stored paths in the DB and the virtual path, root and all the related info.
Well, here is what I would do:
Copy your images to the new directory. (Leave the old directory in place for now)
Run a SQL update script on your DB to change the stored location. (Without knowing your db structure I can't say more.)
Update your app code to point to the new directory.
Test your app to verify that is uses the new directory.
Rename the old directory to something else, so that any link to it would break.
See if anything is broken, and fix it!
I'm using the App_Data folder for uploaded images.
This is because each image is given an ID in the database, and stored in several formats.
I therefore create a directory with the ID as its name, and put all the formats inside it, like this:
App_Data/1/original.jpg
App_Data/1/thumbnail.jpg
And so forth.
This is done because I can delete the directory "1" without causing an application restart.
However I still want to show these images on my site, and App_Data cannot be read by default.
Is there anyway to grant read access to this folder ?
Until now I've been using a generic handler to serve the images, but that's quite an overhead