那麼,答案是:
if (is_uploaded_file(@$_FILES['ulimage']['tmp_name']))
{
$targetfilename = ImageHelper::treatFilename(uniqid() . "_" . $_FILES['ulimage']['name']);
move_uploaded_file($_FILES['ulimage']['tmp_name'], dirname(__FILE__) . "/tmp/" . $_FILES['ulimage']['name']);
ImageHelper::resizeImage(dirname(__FILE__) . "/tmp/" . @$_FILES['ulimage']['name'], dirname(__FILE__) . "/tmp/thumb/" . $targetfilename, $width, $height);
}
但是,也許你想了解一點從網上覆制的代碼和過去在使用之前。使用$ _瓦爾沒有逃逸系統和@隱藏的錯誤是不是真的呼喚信任...
編輯:我給意見,但也許這是更好地給一些解釋爲好。
// first you check if the is done uploading in the tmp directory with is tmp name
if (is_uploaded_file(@$_FILES['ulimage']['tmp_name']))
{
// here, you rebuild a explicit name using the original filename and a
// unique ID to avoid erasing another one
$targetfilename = ImageHelper::treatFilename(uniqid() . "_" . $_FILES['ulimage']['name']);
// you rename the file an put it in ./tmp, a subdir of the
// script file (because of dirname(__FILE__))
move_uploaded_file($_FILES['ulimage']['tmp_name'], dirname(__FILE__) . "/tmp/" . $_FILES['ulimage']['name']);
// Here create a rezided copy
// so it's here you can decide to make it go to ./tmp/thumb
// make sure the dir exists before because you have no clue here
// if ImageHelper will create it for you if not
ImageHelper::resizeImage(dirname(__FILE__) . "/tmp/thumb/" . @$_FILES['ulimage']['name'], dirname(__FILE__) . "/tmp/thumb/" . $targetfilename, $width, $height);
}
男人,像這樣的一個標題並不是真正意義上的。你能想到更多與你的問題有關的東西嗎? – 2009-06-13 08:11:53
好吧。讓我知道什麼是最好的標題.. – wow 2009-06-13 08:16:37