user3425344
user3425344

Reputation: 3537

Symfony UploadedFile not working

I am trying to create a temporary file , Fill it with data and then create a UpladedFile for this temp file. Here goes my code.

$encoded_data = "This is a huge string";
$filename = "tempMaxFile";//$meta_data["uri"];
$handle = fopen($_SERVER['DOCUMENT_ROOT'].$filename, "a+");
file_put_contents($_SERVER['DOCUMENT_ROOT'].$filename, $encoded_data);
$file = new UploadedFile($_SERVER['DOCUMENT_ROOT'].$filename,$filename);
var_dump($file->getClientSize());
die;

But it prints null where it should be printing the size of the file. And I can see the file in my folder with the data in it!

Upvotes: 1

Views: 445

Answers (1)

Carlos Granados
Carlos Granados

Reputation: 11351

If you look at the code for UploadedFile you will see that it does not calculate this size, it expects you to pass it to the constructor

Upvotes: 3

Related Questions