<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
session_start();
$targ_w = $targ_h = 150;
$jpeg_quality = 90;
$ext=$_GET['ext'];
$src = $_GET['p'];
$img_r = imagecreatefromjpeg($src);
$dst_r = imagecreatetruecolor( $targ_w, $targ_h );
imagecopyresampled($dst_r,$img_r,0,0,$_POST['x'],$_POST['y'],
$targ_w,$targ_h,$_POST['w'],$_POST['h']);
unlink($src);
imagejpeg($dst_r,$src,$jpeg_quality);
rename($src,"img/temp_images/".$_SESSION['userid'].".".$ext);
$result=move_uploaded_file(
"/img/temp_images/".$_SESSION['userid'].".$ext",
"/img/".$_SESSION['userid'].".$ext");
if($result)
echo "Success";
else
echo "<br>Fail";
?>
- Safe mode is off
-
No error is displayed despite of putting the following code
ini_set(‘display_errors’,1);
error_reporting(E_ALL); -
The system is running on localhost
- Everything is working except move_uploaded_file() function
- The code is called from an iframe.
- Also I have tried directory(FILE) and many alternatives
Please suggest a solution or a reason to the problem. Do I need to catch the error/warning somewhere using the firs 3 lines? I’m running this on a XAMPP setup ver 2.5.8. I assume since I’m able to create files, I have the permissions to move the file to a folder. And I guess on a localhost there is no hassle for permissions?
You are creating a new image using GD library. Instead of
move_uploaded_file()try usecopywhich to move files from one location to another locationhttp://php.net/manual/en/function.copy.php
Code Example,