I'm doing a paste the link onto
input and then uses PHP(imagecrop) to crop and store the image onto server directory.
$imagesrc = $_GET['img']; $img = file_get_contents($imagesrc); $im = imagecreatefromstring($img); $width = imagesx($im); $height = imagesy($im); $newwidth = '400'; $newheight = '800'; $thumb = imagecreatetruecolor($newwidth, $newheight); imagecopyresized($thumb, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); $filename = basename($imagesrc); imagejpeg($thumb,'image/'.$filename); //save image as jpg imagedestroy($thumb); imagedestroy($im);
My question is how to upload images that is stored in the directory into wordpress? I know how to do it using
<form> using manually but no idea how to do it after successfully cropping the image then upload to wordpress database automatically.
Tried uploading or saving it to wp-content\uploads and then I looked up in to wp-admin/upload.php and the images that I uploaded is not showing there.