php - Upload image error in wordpress custom templete -


i trying code upload image in custom word-press template. working in php. when move on word-press template, shows warning , stop executing script. here code. assume table , folder created proper permission 777.

<?php require('../../../wp-load.php'); require('../../../wp-config.php'); function getimageextension($imagetype) {    if(empty($imagetype)) return false;    switch($imagetype)    {        case 'image/bmp': return '.bmp';        case 'image/gif': return '.gif';        case 'image/jpeg': return '.jpg';        case 'image/png': return '.png';        default: return false;    }  }  if (!empty($_files["uploadedimage"]["name"])) {      $file_name=$_files["uploadedimage"]["name"];     $temp_name=bloginfo('template_directory').$_files["uploadedimage"]["tmp_name"];      $imgtype=$_files["uploadedimage"]["type"];     $ext= getimageextension($imgtype);     $imagename=date("d-m-y")."-".time().$ext;      $tmp=bloginfo('template_directory');     $remain = "/images/".$imagename;     $target_path = $tmp.$remain;      if(move_uploaded_file($temp_name, $target_path)) {          $query_upload="insert images_tbl (images_path) values ('$target_path')";         mysql_query($query_upload) or die(mysql_error());       }else{        exit("error while uploading image on server");     }  } 

?>

output:

warning: move_uploaded_file(/images/16-12-2014-1418709361.gif) [function.move-uploaded-file]: failed open stream: no such file or directory in /opt/lampp/htdocs/wordpress2/wp-content/themes/twentythirteen/saveimage.php on line 31  warning: move_uploaded_file() [function.move-uploaded-file]: unable move '/tmp/phpus9xny' '/images/16-12-2014-1418709361.gif' in /opt/lampp/htdocs/wordpress2/wp-content/themes/twentythirteen/saveimage.php on line 31 error while uploading image on server 

please try  1 more thing  remember when  move file need 2 parameter      file name      b path of folder 1 want move picture. ex :  $destination = "test/". $name;//  path  $answer = move_uploaded_file($_files['user_file']['tmp_name'],$destination); 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -