Detecting corrupted jpg files before or during upload - file-upload

I have an ASP application that uses ASPImage.Image to resize the uploaded image and then save the file to the server and save it in the database. However, it appears that if a user uploads a corrupted file the resulting image is blank white image.
I need a way to check if the file is corrupted before the image is passed to ASPImage.Image, that will then inform the user that the file is corrupted.
Can this be done with javascript, vbscript or ASPImage.Image itself?
Any assistance would be greatly appreciated.
Best Regards,
Paul Jacobs

There is no way to detect a corrupt image in either javascript or vbscript - you will need to try using ASPImage.Image directly.
It has an Error property, this will probably have an error detailing that a corrupt file has been loaded - did you try that? That is, if it is populated, chances are that the file was corrupt.
Additionally, the LoadImage method returns a boolean - I assume it will return false if the image couldn't be loaded due to corruption.

You can use the code here: http://forums.aspfree.com/code-bank-54/pure-asp-upload-script-with-additional-features-94647.html
Then check the image Width and Height - if 0 it means the uploaded file was not a valid image.
This is pure classic ASP code without third party components.

Related

How to get the original fileName in response body of react-native-image-picker?

I have a requirement where I need to get the original file name while picking any document using launchImageLibrary function of react-native-image-picker.
However, the library seems to store the original file in app cache and then picks it up with a different file name, and the original file name is lost in the process. I'm not sure if this issue is present is iOS but it happens in Android. Any help is much appreciated.

Typo3 LTS9 PDF dimensions are not read and displayed in 0x0

I am having an issue with PDF's in the latest Typo3 release. If I add PDF to the Image content element, I get this:
The file info looks like this:
Checking the Image Processing Test of Typo3, no errors are returned. PDF/AI also seems to be fine.
I tested several PDF's and AI files as well, they won't show dimensions either.
I have the suspicion that the command 'identify' does not work within Typo3, it still returns perfect results from shell.
Any idea where to look?
multiple reasons possible:
you just need to reimport metadata (scheduler task)
your PDF is coded in an unsual format (there is more then one option in PDF to include the title image)
missing/wrong rights:
maybe another program is executed from commandline than from PHP.
maybe the file can't be accessed correctly from ghostscript started from web

GEPlugin does not load KML files on VB.NET

I have developed an app using the GEPlugin located at https://code.google.com/p/winforms-geplugin-control-library/.
I use the GEWebBrowser and the GETreeView, and both works nicely.
I only load local kml files on the controls, so the way to do this, is to copy the "KML_Samples.kml" file into the webroot directory, and call the function as follows:
GeWebBrowser.FetchKml(http://localhost:8080/KML_Samples.kml)
Each time I call this method, the event GeWebBrowser_KmlLoaded is launched in the correct way.
However, I have checked lately that this works fine for the two or three first kml files loaded. After this two or three files, when I try to load a new kml file, I can see that the the KML_Samples.kml file has been updated, but the GeWebBrowser_KmlLoaded event IS NOT LAUNCHED!
I have tried to execute the app step by step setting a breakpoint on the line
GeWebBrowser.FetchKml(http://localhost:8080/KML_Samples.kml)
and in this case, I can load the kml files!!.
I have tried to execute some code after this line in order to execute all the pending events, with the following line:
Application.DoEvents()
However, this has not the expected result, and the trouble remains: I'm only able to load the two or three first kml files.
I wonder if something is missing by my side using this control, but I have not found anything on the documentation that could help me.
If anyone could help me with this issue, I would be very thankful .
I answer my own question.
I have detected the GEControl does not works fine with the built-in server. I can load local kml files by sopying them at webroot\KML_Samples.kml, but this only works for the first two or three files to be loaded.
For the following kml files, it doesn't work. I suppose there is some mistake inside the control, so I'm going to develop all the code that load the kml file into a TreeView (I'll try to use the KmlTreeView), and load all the separated points of each kml file into the plugin.

PSPDFKit give error `documentRef is nil , cannot get pageRef`

How would i know file document is corrupt or cannot be loaded in PSPDFKit?
How delegate method should i implement in PSPDFKit to know document is corrupt or cannot be loaded?
The problem is file document does exist?? but don't know is file corrupt or not.
If i know then could download new file document if its corrupt.
Thanks you all !!!!!!
this is the main developer of PSPDFKit.
You can use the [document.isValid][1] property to determine if the document source is valid or not.

Other ways to check the file size before upload

Is there any other way that I can just check the size of a file before upload? The requirement is if the file exceeded the limit, the form mustn't submit. If it's not, I have to do the ordinary upload using the form and I don't have to exactly upload the file to the server using Flash.
Is there any other way that I can just check the size of a file before upload?
Not in JavaScript, the file size is not in the DOM.
when instantiating SWFUpload, there are two parameters you need to pass: file_size_limit, and file_queue_error_handler:
new SWFUpload({
file_size_limit: "10 MB",
file_queue_error_handler: queueErrorHandler,
[...]
})
and then:
function queueErrorHandler(file, errorCode) {
if (errorCode == SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT) {
alert("File exceeds the 10MB limit!");
}
}
this checks if the file size is within limits before starting the upload
with the W3C FileAPI (implemented at least by Firefox 3.6) you can.
See this link for details
http://hacks.mozilla.org/2009/12/w3c-fileapi-in-firefox-3-6/
Cheers
Checking the file size through the SWFUpload control is possible. Just put the SWFUpload control outside of the Web form tags. Tell the user click on the SWFUpload button and point to his upload file. Use javascript to determine the file size, then utilize this information as you see fit such as populating a validation function. Then your main form will need to ask the user to point to their upload file again, and it is this field which will do the actual uploading of the file. When the form is submitted, the SWFUpload control will be completely ignored since it's not part of the main form.