简体   繁体   中英

How to calculate the size of a file?

I have uploaded a file to my web server using a web script. So If I need to get the size of that, how can I get it through the php ?

<?php
session_start();
define('incall', true);
include("connection.php");

if(!@include_once('config.php'))
{
    header('HTTP/1.0 404 Not Found');
    exit;
}

$to=$_POST['to'];
$message    = str_replace('{link}', $download_path.$_POST['filename'].'.mp3', $email_body);
echo $fname." size";
die;
$fname=$download_path.$_POST['filename'].'.mp3';
$headers  = "From: ".$_POST['from'];
$subject=$_POST['subject'];
$date=date("Y/m/d");
$time=date('h:i:s A');
$size=filesize('$fname');
$username=$_SESSION['username'];
if(mail($to, $subject, $message, $headers))
{   
    $query=mysql_query("INSERT INTO sent values('$username', '$to','$date', '$time', '.mp3', '$size' )");
    header("location:mailsent.php?");
}
else
    exit('Error! VoiceMail not be send.');
?>

I'm getting the download link in the email. But still the $fname is not existing. I wonder why ??

您是否尝试过文件大小功能?

您可以使用$_FILES['userfile']['size'] ,其中userfile文件输入字段的名称。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM