Jump to content

Recommended Posts

Trying to upload an image and get the following error:

 

Warning: fopen(1b823dd333cd6295592e170c0a939d7e.jpg) [function.fopen]: failed to open stream: Permission denied in /home/sfengine/public_html/admin/includes/global.inc.php on line 68

 

Warning: fwrite(): supplied argument is not a valid stream resource in /home/sfengine/public_html/admin/includes/global.inc.php on line 69

 

Warning: fclose(): supplied argument is not a valid stream resource in /home/sfengine/public_html/admin/includes/global.inc.php on line 70

Unable to open the file: 1b823dd333cd6295592e170c0a939d7e.jpg

 

The folder is set to CHMOD 777.

 

The upload script is:

 

<h2>Add Category</h2>
<?php
if($_POST['action']	==	'add_cat'){
$cat_name	=	$_POST['cat_name'];
$cat_description	=	$_POST['cat_description'];
$cat_image	=	$_FILES['cat_image'];
//Image Types
$AllowedImages	=	array('image/jpeg','image/pjpeg');
if(empty($cat_name) || empty($cat_description) || $cat_image['error'] != 0 || !in_array($cat_image['type'], $AllowedImages)){
	echo '<p>Please fill in all fields correctly.</p>';
} else{
	//Continue & Add to DB
	$cat_image_name	=	md5(microtime()).'.jpg';
	//Write Original File
	WriteFile($cfg['catimages']['folder'].$cat_image_name, file_get_contents($cat_image['tmp_name']));
	//Create smaill sized thumbnail
	$ImageFunctions->Open($cfg['catimages']['folder'].$cat_image_name);
	$ImageFunctions->Resize(109,72);
	$ImageFunctions->RawOutput();
	WriteFile($cfg['catimages']['folder'].$cat_image_name, $ImageFunctions->Output['Content']);
	$cat_image	=	$cat_image_name;
	$cat_slug	=	Word2Slug($cat_name);
	$Query	=	"INSERT INTO `product_cats` (`cat_name`,`cat_slug`,`cat_image`,`cat_description`) VALUES('$cat_name','$cat_slug','$cat_image','$cat_description')";
	$Db->Query($Query);
	echo '<p>"'.$cat_name.'" Added.</p>';
}
}
?>
<form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post" enctype="multipart/form-data">
<input type="hidden" name="action" value="add_cat" />
<p>Category Name: <input type="text" name="cat_name" /></p>
<p>Category Image (Jpeg Only): <input type="file" name="cat_image" />
<p>Category Description:</p>
<p><textarea name="cat_description" style="width:500px;height:250px;font-family:Arial, Helvetica, sans-serif;"></textarea></p>
<p><input type="submit" value="Add Category" /></p>
</form>

 

Function is:

 

//Write File
function WriteFile($File, $Data){
$handle	=	fopen($File, 'w');
fwrite($handle, $Data);
fclose($handle);
}

 

 

Any ideas?

 

Thanks in advance,

Nick.

Link to comment
https://forums.phpfreaks.com/topic/143660-fopen-permission-denied-error/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.