Uploading multiple files then resize
Posted: Thu Dec 07, 2006 6:54 pm
Everah | Changed [ code ] tags to [ php ] tags.
Warning: imagecreatefromjpeg(screens/KnowWiiDOTcom) [function.imagecreatefromjpeg]: failed to open stream: No such file or directory in /mounted-storage/home29a/sub002/sc18478-RGIJ/knowwii.com/add_screen_shot.php
My first file is called file[0] then my 2nd file is called file[1]
any i deas on how to fix this problem?
Everah | Changed [ code ] tags to [ php ] tags.
Warning: imagecreatefromjpeg(screens/KnowWiiDOTcom) [function.imagecreatefromjpeg]: failed to open stream: No such file or directory in /mounted-storage/home29a/sub002/sc18478-RGIJ/knowwii.com/add_screen_shot.php
My first file is called file[0] then my 2nd file is called file[1]
any i deas on how to fix this problem?
Code: Select all
$files = array_values($HTTP_POST_VARS['file']);
$user_id = $userdata['user_id'];
$game_id = $HTTP_GET_VARS['id'];
$date = time();
//loop threw all cheats submitted
for ($x =0; $x < count($HTTP_POST_VARS['file']); $x++)
{
//if cheat title or cheat not blank
if ( $files[$x] <> "")
{
print $_FILES["files[$x]"]["name"] .'<br>';
$pos = strpos($_FILES["files[$x]"]["name"],'.');
$file_type = strtolower(substr($_FILES["files[$x]"]["name"], $pos + 1, strlen($_FILES["files[$x]"]["name"]) - $pos +1));
move_uploaded_file($_FILES["files[$x]"]["tmp_name"], "screens/KnowWiiDOTcom" . $_FILES["files[$x]"]["name"]);
// Create thumbnail canvas
$destimg = imagecreatetruecolor ("320", "240") or die ("Problem In Creating image");
// Use one or use conditional to select i.e. if JPEG
$srcimg = imagecreatefromjpeg ("screens/KnowWiiDOTcom" . $_FILES["files[$x]"]["name"]) or die ("Problem In opening Source Image"); // For JPEG
// Resample the image from $srcimg to the $destimg
imagecopyresampled ($destimg, $srcimg, 0, 0, 0, 0, "320", "240", imagesx($srcimg), imagesy($srcimg)) or die ("Problem In resizing");
// Save JPG
imagejpeg ($destimg, "screens/KnowWiiDOTcom_thumb_" . $_FILES["files[$x]"]["name"]) or die("Problem In saving");
}