php - Code to get file size after upload and insert into table is not working -


i have mysql/php project has files table creates virtual folders , links uploaded files, upload , accessing works fine, have added field 'size' , have amended code update file size after upload table, code not working. no errors , file still gets uploaded code inserting null value relevant field. code below:

global $dal; $tbldocs = $dal->table("doc_files"); $filearray = my_json_decode($values["file"]);  for($i = 0; $i < count($filearray); $i++) { $tbldocs->value["parent_folder_id"]=$_session["current_folder"]; $tbldocs->value["file_type"]="file"; $tbldocs->value["file"]=my_json_encode(array($filearray[$i])); $tbldocs->value["hash"]=generatepassword(hash_length); $tbldocs->value["name"]=$filearray[$i]["usrname"]; $tbldocs->value["ownerid"]=$_session["user_id"]; $tbldocs->value["created"]=now(); $tbldocs->value["filesize"]=formatbytes($filearray[0]["size"],2);  $tbldocs->add();  } 

you're using wrong index:

$tbldocs->value["name"]=$filearray[$i]["usrname"];                                    ^^--here use loop index  $tbldocs->value["filesize"]=formatbytes($filearray[0]["size"],2);                                                    ^---hard-coded index 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -