PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
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]
$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");
}
$file_count = $HTTP_POST_VARS['hiddenField'];
$user_id = $userdata['user_id'];
$game_id = $HTTP_GET_VARS['id'];
//loop threw all screen shots submitted
for ($x =0; $x < $file_count; $x++)
{
print $_FILES["file"]["name"][$x] . " $x <br>";
//if file field not blank
if ( $_FILES["file"]["name"][$x]<> "")
{
$pos = strpos($_FILES["file"]["name"][$x],'.');
$file_type = strtolower(substr($_FILES["file"]["name"][$x], $pos + 1, strlen($_FILES["file"]["name"][$x]) - $pos +1));
move_uploaded_file($_FILES["file"]["tmp_name"][$x], "screens/KnowWiiDOTcom" . $_FILES["file"]["name"][$x]);
// 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["file"]["name"][$x]) 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["file"]["name"][$x]) or die("Problem In saving");
}
}