Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get file size in Perl

Status
Not open for further replies.

hazg

Programmer
Dec 14, 2004
10
FR
Hello,

I was wondering if there was a way of getting the size of a file in Perl (i.e. 40kb).

I am getting the file and saving it to its directory via the mirror command.

Cheers
 
Greetings...
I'm new to Perl, and need help writing a script that will tell me the file size of a file I wish to upload via an html form before I actually upload it. The below script is an activex example of what I want to do. I just don't want to use activex for my project. Thanks...

<html>
<head>
<title>File System Object Example</title>
<script language="javascript">
<!--//
var oFileSystem;
oFileSystem = new ActiveXObject("Scripting.FileSystemObject");
function getFile(sFilePath){
frm.display.value = oFileSystem.GetFile(sFilePath).Size;
}
</script>
</HEAD>

<BODY>
<b>Select the File you would like to get the size of</b>
<form name="frm">
<input type="file" name="filPath" onchange="getFile(this.value)">
<input type="text" name="display">
</form>

</body>
</html>
 
as fas as I know it's not possible with just perl. You will need to use something client side to get the file size and load that value in a form field and check the value of that form field. Maybe someone else will know something I am not aware of.
 
Code:
It depends whether your web page is LOCAL...

You only have client-side functionality until submission
 _______________                 _______________
|               |               |               |
| your computer |               | server        |
|               |    submit     |               |
| LOCAL         | ------------> | REMOTE        |
|               |               |               |
| javascript    |               | Perl          |
|_______________|               |_______________|

or REMOTE...

You have server-side functionality that you can make use of
 _______________                 _______________
|               |               |               |
| server        |               | server        |
|               |    submit     |               |
| REMOTE        | ------------> | REMOTE        |
|               |               |               |
| js & Perl     |               | js & Perl     |
|_______________|               |_______________|

You will be able to get the file size - however, it might be a bit awkward


Kind Regards
Duncan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top