Hey everyone,
I'm creating a profile account login where a user can input all their information and upload a profile pic (with cropping features).
I'm currently using "PHP & jQuery image upload and crop v1.2"
Link to source:
http://www.webmotionuk.co.uk/php-jqu...-and-crop-v11/
I'm using wordpress and I have created a custom page to implement this feature.
After some minor adjustments I have gotten the tool working (for the most part).
I am able to upload a pic into the specified directory and select my area for cropping.
The issue comes when I try to save the new thumbnail after I have cropped the original image. I get a 404 error.
The reason I get this error is because my wordpress site is under a different directory than the root.
My wordpress is in a subdirectory like:
mysite.com/wordpress_site/
My jQuery script is located inside my custom_page_template.php for example:
mysite.com/wordpress_site/wp-content/themes/my_theme/custom_page_template.php
When I access the page of where my script is hosted, it will automatically create me a new directory "upload_pic" where my images will be uploaded.
The link to the images uploaded will look like:
mysite.com/upload_pic/resize_1234.jpg
Notice that the "upload_pic" is not in the wordpress directory. That's okay with me for now...
Issue #1 (Now Fixed)
Whenever I uploaded a image file, the output img src link would be:
mysite.com/my_custom_page/upload_pic/resize_1234.jpg
The actual link to the uploaded image:
mysite.com/upload_pic/resize_1234.jpg
I rewrote the script to go back one directory inorder for the image to appear.
The reason I mention this is because when it comes to cropping the image, the new cropped image wont save. I know this has to do with the directory of the image of where it is trying to store it at.
I believe is has a lot to do with variables $thumb_image_location and $large_image_location in the following script:
PHP Code:
if (isset($_POST["upload_thumbnail"]) && strlen($large_photo_exists)>0) {
//Get the new coordinates to crop the image.
$x1 = $_POST["x1"];
$y1 = $_POST["y1"];
$x2 = $_POST["x2"];
$y2 = $_POST["y2"];
$w = $_POST["w"];
$h = $_POST["h"];
//Scale the image to the thumb_width set above
$scale = $thumb_width/$w;
$cropped = resizeThumbnailImage($thumb_image_location, $large_image_location,$w,$h,$x1,$y1,$scale);
//Reload the page again to view the thumbnail
header("location:".$_SERVER['REQUEST_URI']);
exit();
}
Basically, I need to properly set the correct path to my images when uploading and cropping my image.
Without wordpress, the script works just fine. I am able to upload and crop. All my original image files and cropped files can be seen in the uploaded directory.
However, I want to implement this into wordpress but the issue with image path is giving a hard time. Any advice would be appreciated!
Please pm me if you want to see my live script. Thanks!