file - php move_uploaded_file not working -
usually i'd simplify code this, or show part thats giving me trouble. in case have no idea going wrong pasted entire thing in. sorry.
ok below script gets values sent ajax , uploads them sql data base. after doing moves image folder folder.
the entire script works fine, supposed do, except 'move_uploaded_file' bit. sql part correctly, , session names, string edits, etc... correct.
i've echoed names of files script produces , correct. folders can read+written too. , file waiting moved present in folder.
what missing? why move_uploaded_file not working? in advance all.
--changed move_uploaded_file() rename(), still not working--
<?php session_start(); unset($_session['reference']); $name = $_get['name']; $category = $_get['category']; $subcategory = $_get['subcategory']; $date = $_get['date']; $address = $_get['address']; $city = $_get['city']; $state = $_get['state']; $host = $_get['host']; $info = $_get['info']; $adder = $_session['user']; //turn array $array = array(); $array[0]=$name; $array[1]=$category; $array[2]=$subcategory; $array[3]=$date; $array[4]=$address; $array[5]=$city; $array[6]=$state; $array[7]=$host; $array[9]=$info; $array[11]=$adder; try { $con = new pdo('mysql:host=localhost;dbname=test'); //$con->setattribute(pdo::attr_errmode, pdo::errmode_exception); $refid=$con->prepare(" select max(id) createx "); $refid->execute(); $id = $refid->fetchcolumn(); $id=$id+1; $newdate = str_replace('-', '', $date); $reference = $id.$newdate; $array[10]=$reference; $array[8] = $_session['imagepath'].$reference.'.'.$_session['imageext']; $insert = $con->prepare(" insert createx (name,category,subcategory,date,address,city,state,host,imagepath,info,ref,adder) values (?,?,?,?,?,?,?,?,?,?,?,?) "); $insert->execute($array); rename( '../tempuploads/'.$_session['imagepath'].$_session['imageext'] , '../uploads/'.$_session['imagepath'].$reference.'.'.$_session['imageext'] ); } catch(pdoexception $e) { //try echo 'error'; //echo 'error: ' . $e->getmessage(); } $_session['reference'] = $reference; unset($array); session_write_close(); ?>
move_uploaded_file()
files uploaded via post. source filename should come $_files['xxx']['tmp_name']
, , interpreted relative directory used temporarily hold posted files.
if want move other file, use rename()
.
Comments
Post a Comment