PHP+HTML: file not loaded from form -


in form user can choose upload file. so, here's correspondent field in form. here html code:

<p>  <label>allega fattura</label>  <span class="field">  <input type="file" name="allegato_fattura" id="allegato_fattura" value="sfoglia..." /> </span> 

and when submit button clicked, here go:

...     define("dir_fatture","fatture/");     $fatturafilename;     $addedfattura = false;      if (file_exists($_files['allegato_fattura']['tmp_name']) || is_uploaded_file($_files['allegato_fattura']['tmp_name'])) {         $addedfattura = true;         $fatturafilename = $_files['allegato_fattura']['name'];          if (file_exists(dir_fatture.$_files['allegato_fattura']['name'])){             $fatturafilename=time()."_".$_files['allegato_fattura']['name'];             $_files['allegato_fattura']['name']=$fatturafilename;         }          move_uploaded_file($_files['allegato_fattura']['tmp_name'], dir_fatture.$_files['allegato_fattura']['name']);     } 

and not work. wrote same files/script other forms , worked, not know why not: no file loaded , variable $fatturafilenale remains null , neither name file written in database. directory "fatture" exists in server in correct path...

you must use enctype="multipart/form-data"

<form name="item" method="post" enctype="multipart/form-data"> 

Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -