mysql - i have some issue to get images in slim framework in php -


    $app->post('/upload_media', function($request, $response){     $input = $request->getparsedbody();     $files = $request->getuploadedfiles();     $newfile = $files['upload_file'];     $mediaurl = uploadedmediafile($newfile);     $sql = "insert tbl_media_files (media_url,media_type,added_on) values (:media_url,:media_type,:added_on)";         try {             $sth = $this->db->prepare($sql);             $sth->bindparam("media_url", $mediaurl);             $sth->bindparam("media_type", $input['media_type']);             $sth->bindparam("added_on",date('y-m-d h:i:s'));             $sth->execute();             $media_id = $this->db->lastinsertid();               $data = $this->db->prepare("select * tbl_media_files media_id=:media_id");             $data->bindparam("media_id", $media_id);             $data->execute();             $user['data']=$data->fetchobject();              $user['success'] = "true";             $user['message']="media upload success.";         }         catch(pdoexception $e)         {                //echo '{"error":{"text":'. $e->getmessage() .'}}';             $user['success'] = "false";             $user['message']="media upload failed";         }          return $this->response->withjson($user);          });   image upload function       function uploadedmediafile($uploadedfile)     {         if($uploadedfile->geterror() === upload_err_ok)            {             $uploadfilename = $uploadedfile->getclientfilename();             $type = explode('/', $uploadedfile->getclientmediatype());             $type = $type[0];             $name = uniqid($type.'-');             $name .= $uploadedfile->getclientfilename();              $large_file = '../upload/large/'.$name;             $thumb_file = '../upload/thumb/'.$name;              $uploadedfile->moveto($large_file);               $photourl = "http://stagebook.us-east-2.elasticbeanstalk.com/upload/large/".$name; // live             return $photourl;            }      } 

this api upload_media , uploadedmediafile function on same file src/routes.php

i have try upload image image upload success , return full path of image path run on web-browser (crome) file cant show there message show like

"method not allowed method not allowed. must 1 of: options"


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -