Move file upload not working in php -
i have facing problem on file uploading code multiple files additional input field mention name of customer
$titles=$_request['doc_title']; $tmp_names=$_files['filename']['tmp_name']; $requestid=$_request['reqno']; //echo $_server['http_host']; //echo $_server['request_uri']; die; $url= 'http://' . $_server['http_host'] . $_server['request_uri']; $upload_dir=str_replace('/index.php','/',$url); $time = time(); $arradata=array(); $filearray=array(); foreach($_files['filename']['name'] $key=>$value){ $arradata[$key]['doc_title']=$titles[$key]; $arradata[$key]['file_name']=$time.$value; $arradata[$key]['tmp_name']=$tmp_names[$key]; $arradata[$key]['req_id']=$requestid; $pathandname = $upload_dir."temp/moredocument/" . $time.$value; $move_files=move_uploaded_file($tmp_names[$key], $pathandname); }
i have multiple file upload use foreach. $_files output 2 image upload
array ( [filename] => array ( [name] => array ( [0] => 1472470251_example_001.pdf [1] => 1472462805_example_001.pdf ) [type] => array ( [0] => application/pdf [1] => application/pdf ) [tmp_name] => array ( [0] => /tmp/phpd3tfnc [1] => /tmp/php6w0v8w ) [error] => array ( [0] => 0 [1] => 0 ) [size] => array ( [0] => 53915 [1] => 53915 ) ) )
please error is.
for uploading file need pass absolute url of file.
here have used
$url= 'http://' . $_server['http_host'] . $_server['request_uri']; $upload_dir=str_replace('/index.php','/',$url);
this give http://
url can not move file.
$titles=$_request['doc_title']; $tmp_names=$_files['filename']['tmp_name']; $requestid=$_request['reqno']; //this roor url can use __dir__ or dirname(__file__) $upload_dir= '/'; $time = time(); $arradata=array(); $filearray=array(); foreach($_files['filename']['name'] $key=>$value) { $arradata[$key]['doc_title']=$titles[$key]; $arradata[$key]['file_name']=$time.$value; $arradata[$key]['tmp_name']=$tmp_names[$key]; $arradata[$key]['req_id']=$requestid; //make sure have created directories $pathandname = $upload_dir."temp/moredocument/" . $time.$value; $move_files=move_uploaded_file($tmp_names[$key], $pathandname); }
Comments
Post a Comment