<?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";
?>
- 安全模式是關閉
未顯示錯誤,儘管把下面的代碼移動上傳的文件的問題
的ini_set的( '的display_errors',1); error_reporting(E_ALL);
該系統是運行於localhost
- 一切工作除了move_uploaded_file()以功能
- 的代碼從一個iframe調用。
- 我也試過目錄(FILE)和許多替代
請提出一個解決方案或原因的問題。我需要使用第一行3來捕捉錯誤/警告嗎?我在XAMPP 2.5.8版本上運行。我假設,因爲我能夠創建文件,我有權將文件移動到文件夾。我想在本地主機上沒有權限的麻煩?
我懷疑路徑'/ IMG/...'是正確的。你的硬盤根目錄下有一個'img' **文件夾? – deceze
'「/ img/temp_images /」.$_ SESSION ['userid']。「。$ ext」,' - 這是什麼?你爲什麼使用它?你爲什麼認爲你的文件在那裏?你應該有這樣的東西:'move_uploaded_file($ _ FILES [「picture」] [「tmp_name」],「/ img /".$_ SESSION ['userid']。」。$ ext「(;' –
// unlink-刪除文件 問題是你在move_uploaded_file之前取消了鏈接,導致unlink在上傳之前刪除你的文件。你應該在move_uploaded_file之後取消鏈接。 –