Expand|Select|Wrap|Line Numbers
- <HTML>
- <Head>
- <Script Language=JavaScript>
- function getStats(fName){
- nullIMG.src = fName;
- fullName = fName;
- shortName = fullName.match(/[^\/\\]+$/);
- splitName = fullName.split(".");
- fileType = splitName[1];
- fileType = fileType.toLowerCase();
- if (fileType == 'gif' || fileType == 'jpg' || fileType == 'jpeg')
- {
- checkIt = fileSize(fullName);
- if (parseInt(checkIt) > 30000){alert('Max File Size is 30Kb');Form1.reset()}
- else {
- Form1.dispSize.value = checkIt;
- Form1.dispName.value = shortName;
- Form1.dispW.value = nullIMG.width;
- Form1.dispH.value = nullIMG.height;
- }
- }
- else {
- alert("You must select an image file!");
- Form1.reset();
- }
- }
- divStr = "<Div Style='Position:Absolute;Top:-2000'><IMG Src=Null ID=nullIMG></Div>"
- document.write(divStr)
- </Script>
- <Script Language=VBScript>
- Function fileSize(fileSpec)
- Dim isSize
- Set fso = CreateObject("Scripting.FileSystemObject")
- Set contentFile = fso.GetFile(fileSpec)
- isSize = contentFile.Size
- fileSize = isSize
- Set contentFile = Nothing
- Set fso = Nothing
- End Function
- </Script>
- </Head>
- <Body>
- <Form name='Form1'>
- Choose an image: <input type="file" name="isIMG" onChange="getStats(this.value)"><br>
- File Name: <input name='dispName' size=20><br>
- File Size: <input name='dispSize' size=10><br>
- Width: <input name='dispW' size=5><br>
- Height: <input name='dispH' size=5><br>
- <input type=Reset><br>
- <input type=submit value="Submit Form">
- </Form>
- </body>
- </html>
At that point, for example, i want to choose an image file whose name is picture.2007.05.18.gif , but with these codes i always get alert. How can i detect such these files extensions ?
Thank you