We have an aspx-page in which files are uploaded to a server. What is important here is that the files preserves the filecreationtime.
What I'm doing after the file is uploaded to the server is trying to get the file creationtime from the source file (via FileInfo.CreationTimeUtc or File.GetCreationTimeUtc) so that I can update the target file.
The program is throwing an "Unauthorized Access Error" (on my development machine in debug mode, client and server is the same virtual machine) and on the production machine it is returning "1-1-1601 0:00:00".
How can I solve this problem.
Thanks
I found a solution to my problem. As a workaround, I use a javascript function tied to the onClientClick event (fires before the onClick) of the button excuting the upload. The FileUpload component has a property [files] an object array holding the selected file(s). An object has a property lastModifiedDate. This value I store in a hiddenfield. In the onClick method I retrieve that value.
Related
I am using RadAsyncUpload control from Telerik to upload a file on the server. It is working well locally (on localhost) but not in the server. What did I miss?
(When I select a file to upload the dot becomes red instead of green)
I had the same behavior and it was a folder permissions issue.
Another symptom in this case, Chrome DevTools console was showing the following error when I attempt to upload a file:
HTTP Error code is 500
There is a temp folder where RadAsyncUpload saves files temporarily. If you don't define the TemporaryFolder property on the RadAsyncUpload control, the default will be in your App_Data\RadUploadTemp folder. If IIS_USERS don't have write permissions to this folder, the upload can't save a file here. It will work on your localhost because you have write permissions to that folder. Here's how to give the permissions necessary.
Right click on the App_Data\RadUploadTemp folder on server and
select proprties
Select Security tab
Click "Edit..." button
Under "Group or user names:", select IIS_USERS
Under "Permissions for IIS_USERS", check Write in the Allow
column.
Note: This was IIS 7 on Windows 2008 R2 Server.
The dot could become red either when the allowed file extension validation failed or when the file size exceeds the allowed one.
You can attach to the OnClientValidationFailed and OnClientFileUploadFailed events and check what the exact error is and fix it.
The Troubleshooting article offers additional information about the different errors and how to solve them.
Am developing asp .Net web application.
In one of my aspx file am using file to download using generic handler. Everything works great. But when am testing i felt a strange problem. That, if am uploading a image or document with file name containing aspx character for Eg; aspxphoto as file name.
Uploading doesnt have any any problem but when i try to download it is throwing error in Generic handler file as
Object reference not set to an instance of an object.
Can anyone help me why this problem happends and how can i fix it?
You will not be able to do this. The IIS handler wants to "handle" the ASPX. You should simply not allow it, or if you have to, rename it to .aspx.uploaded or something. If you allowed, it you could open yourself to hacking.
As another option, you may be able to create a virtual that implements ("no processing") - possibly using the HTTP Handler under the virtual and just disabling script / execute permissions (under handler >> Edit Feature Permission >> Script OR under Virtual >> Edit permissions >> Special >> Turn Execute off.
I would not recommend the last, since it will add complexity when migrating between test and live AND for recovery (DR).
I am working on a bug fixing for a old asp web page. In this page, there is one field as file for user to browse a file for update. Here is what is like in the asp page:
<input type="file" name="ufile" size="50">
In the browser, this field looks like a text field and a "Browse" button. When use click on another submit button, the input field "ufile" is used for gettting file name for uploading. The asp file has a customized clsMyQuest.asp page to get query string or object. However it looks like broken when the asp project is moved from Windows server to a Linux server.
I don't want to spend time to fix the problem of clsMyQuest.asp file. Is there any way to get the file name in asp for this field "ufile". I guess that the value of this field should be an object of file or something. This object should be retrievable from Request and then the file name may be property of the object. For example, if the user click on "Browse" button to get a file like "C:\Documents and Settings\Documents\user1\example file.pdf", how can I get the file name "example file.pdf"?
If you're using the ASPUpload server component then you can access it by File.FileName
I assume you are running ASP on Mono, since it's a Linux server. You'll need to install the ASPUpload server component. From what i've heard it's tricky to get the component working on Linux
http://www.aspupload.com/
I'm working on an ASP.NET web application for our corporate intranet users. I have a form where a user should provide a path to the file on the local network (something like "\localServer\someFolder\someFile.ext") without uploading the actual file. The issue is that users don't want to type the whole file path and want to use some kind of visual browse dialog.
The standard HTML <input type=file> element allows to browse for a file, but most of the browsers (except for IE) don't allow to access file's full path, so I think it should be done by some external component like Silverlight, Flash, Java applet etc.
I tried to do it with Silverlight, but I'm getting a SecurityException when trying to access file's full path using Silverlight's OpenFileDialog class.
This java applet http://jumploader.com/demo_images.html seems to do something similar to what I'm looking for, but it's focused on uploading files - I only need to be able to get file's full path and pass it to the server as a string.
Any suggestions would be appreciated.
Telerik ASP.NET AJAX RadFileExplorer has the functionality you're looking for:
http://www.telerik.com/products/aspnet-ajax/fileexplorer.aspx
You can use their Custom File Content Provider to hook the GUI to your server's file system.
http://demos.telerik.com/aspnet-ajax/fileexplorer/examples/server-sideapi/dbfilebrowsercontentprovider/defaultcs.aspx
This should be possible with Flash's uploading capabilities. SWFUpload has an API that you may be able to access from JavaScript to extract the selected file name without actually uploading anything. See docs here, for example getFile():
getFile is used to retrieve a File Object from the queue. The file retrieved by passing in a file id (the id property from a file object) or a file index (the index property from a file object).
I have a FileUpload control from which I need the path of a text file. After selecting the file, I need to open and read the data from the text file. For this, I used the following code to open the text file.
fp = File.OpenText(FileUpload2.PostedFile.FileName);
This is working fine on my system. The FileUpload2.PostedFile.FileName property gives the full path of the file. The File.OpenText(() method opens the selected file. But when I run my project in IIS, it gives the following error:
"File.OpenText is not declared."
The FileUpload2.PostedFile.FileName property is not retrieving the full path. It retrieves only the file name. What could be the reason?
This is a typical client server issue. On your system it works, because you are the client and the server, but on IIS (I assume you mean IIS on a test/production server) it looks for the file on the IIS server system while you select the file on your system.
You should use the FileUpload2.PostedFile.InputStream property instead of the filename property.
File f = new File("x.txt");
if(f.exists())
{
.....
}