File uploads to another directory other than spcified directory in PHP code -


i have folder struct this:

 admin-panel      -- thesis-scripts            -- add_thesis.php   uploads 

and trying upload .docx file uploads directory. here code:

$targ_dir = "uploads/"; $targ_file = "../" . $targ_dir . basename($_files["thesisfile"]["name"]); $flagok = 1; $tempfolder = $_files['thesisfile']['tmp_name']; if(move_uploaded_file($tempfolder, urlencode($targ_file))){     echo $targ_file; }  

however, code above results file upload inside thesis-scripts folder. how can move file uploads folder? help. purposely added ../ in $targ_file because save file path in database.

upload_tmp_dir need, change default temporary directory, according documentation here

upload_tmp_dir string temporary directory used storing files when doing file upload. must writable whatever user php running as. if not specified php use system's default.

if directory specified here not writable, php falls system default temporary directory. if open_basedir on, system default directory must allowed upload succeed.

you have 2 choices either write in php code:

ini_set('upload_tmp_dir','your/path');  

or change in php.ini uncomment upload_tmp_dir , use path needed


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -