Tuesday, March 30, 2010

PHP error on IIS

FastCgiModule
Data1 FASTCGI_RESPONSE_ERROR
Data2 PHP Warning: Unknown: open_basedir restriction in effect. File(C:\inetpub\rewards\index.php) is not within the allowed path(s): (C:\Windows\Temp) in Unknown on line 0
PHP Warning: Unknown: failed to open stream: Operation not permitted in Unknown on line 0

ErrorCode 5

The way to solve this is to comment the line on open_basedir in php.ini

Flash CS3 Alpha Tweening

In order for alpha to work, we have to set the text to static instead of dyanamic. It should still work as usual for images. if problem persists, close windows and make sure that the file is exported to the right place.

Tuesday, March 23, 2010

PHP File Upload

1. Setup .ini file within the directory to include the following lines:
post_max_size = 10000000
upload_max_filesize = 10000000

2. Make sure that HTML code contains the MAX_UPLOAD_SIZE hidden field

3. Use the following codes:
function uploadPicture() {

$uploaddir = "issuepics";

$pext = getFileExtension($_FILES['txtImgFile']['name']);
$pext = strtolower($pext);

if (($pext != "jpg") && ($pext != "jpeg"))
{
unlink($_FILES['txtImgFile']['tmp_name']);
return "Error: Extensions Unknown, only JPEG is allowed.";
}

// Resize image
$imgsize = getimagesize($_FILES['txtImgFile']['tmp_name']);
$imgfile = $_FILES['txtImgFile']['tmp_name'];

if (($imgsize[0] > 640) || ($imgsize[1] > 480))
{
$tmpimg = tempnam("/tmp", "MKUP");
system("djpeg $imgfile >$tmpimg");
system("pnmscale -xy 640 480 $tmpimg | cjpeg -smoo 10 -qual 50 >$imgfile");
unlink($tmpimg);
}

// Rename image
global $finalFileName;
$finalFileName = getRandomKey() . "." . $pext;
$newfile = $uploaddir ."/" . $finalFileName;

// copy image into directory
if (is_uploaded_file($imgfile))
{
if (!copy($imgfile,"$newfile"))
{
return "Error: Problem uploading file";
}
}

unlink($imgfile);

return "";

}

function getRandomKey() {
$rand = time() . rand(0,1000);
return $rand;
}

Saturday, March 13, 2010

503 Service Unavailable

This is likely due to the IIS application pool not being started.