php - Uploading image after image and displaying them all -


i've asked couple of questions regarding , each step gets me closer still doesnt work intended.

i want upload image , write textfile, when upload image written end , on forth. you'll have long file lots of images.

as far can tell code should work doesn't. here link site website testing. testing maybe useful , below code.

it creates empty element @ end of array you'll see testing site.

the php:

$sfilename = "imgdb.txt";  ($i=0 ; $i < count($_files) ; $i++) {     move_uploaded_file(         $_files['file-'.$i]['tmp_name'],         "img/". $_files['file-'.$i]['name']     ); }  $simgs = file_get_contents($sfilename); //gets string file.  if (json_decode($simgs, true) != false) {     $ajimgs = json_decode($simgs, true); } else {     $ajimgs = array(); }  $aoutput = array_merge ($ajimgs, $_files);  $asendtofile = json_encode(     $aoutput,     json_pretty_print | json_unescaped_unicode ); file_put_contents($sfilename, $asendtofile); 

some remarks

  • if move_uploaded_file call not protected further, allows upload files, including script files - opens security vulnerability in application - check mime-type , file-extension avoid this
  • json_decode returns null if input value empty or cannot decoded - not false in code
  • appending array not done array_merge, overrides properties of $_files of previous execution - use $aoutput[] = $_files; instead

Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -