Page 1 of 1

open stream errorr Helpp !!

Posted: Thu Mar 16, 2006 8:34 am
by fuchyst
i was created a perfect marketing script but i have this errorr.. i don!t sleep 4 days :cry: my brain is stop :P help mee


Warning: copy(/../uploadedimages/539915.gif): failed to open stream: No such file or directory in C:\web\home\vhosts\turkticareti.net\httpdocs\admin\upload_image_product.php on line 53

Warning: Cannot modify header information - headers already sent by (output started at C:\web\home\vhosts\turkticareti.net\httpdocs\admin\upload_image_product.php:53) in C:\web\home\vhosts\turkticareti.net\httpdocs\admin\upload_image_product.php on line 90

Posted: Thu Mar 16, 2006 8:40 am
by feyd
doesn't sound perfect if it has errors. :P

You're trying to copy a file that's below root, that's not possible. You're probably thinking that using a leading slash to copy() is relative to the document root of your website, well it isn't. It's absolute to the server's file root. Try removing the leading slash, see what realpath() tells you, or use $_SERVER['DOCUMENT_ROOT']

filess and other infos

Posted: Thu Mar 16, 2006 10:43 am
by fuchyst
feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


i did it but don't work..

my site adress..

turkticareti.net

my site dir adress:

[b]C:\web\home\vhosts\turkticareti.net\httpdocs\[/b]

im too bad.. thanks..  

files here..


[b]upload image product.php[/b]
------------------------------------------

Code: Select all

include_once "db.php";

$config=mysql_fetch_array(mysql_query("select * from b2b_config"));
		$pid=$_REQUEST["pid"];
		$num=$_REQUEST["num"];

if (is_uploaded_file($_FILES['userfile']['tmp_name'])) 
{
	$realname = $_FILES['userfile']['name'];
	if ($_FILES['userfile']['size']>($config["sb_image_size"]))
	{
	$mess="Uploaded files must be less than ".($config["sb_image_size"]/1000)."k. Please try again";
	}
	elseif($_FILES['userfile']['size']<=0)
	{
	$mess="File could not be uploaded. Please try again";
	}
	else
	{

//	echo $realname . ", size: ". $_FILES['userfile']['size'] . " [ ";
	$insert="no";
	switch($_FILES['userfile']['error'])
	{ case 0: $mess = "Image uploaded successfully"; $insert="yes";	  break;
	  case 1:
	  case 2: $mess = "Error : File size more than maximum size allowed by server";break;
	  case 3: $mess = "Error : File partially uploaded"; break;
	  case 4: $mess = "Error : No File Uploaded";
	  break;
	}
//	echo $mess . " ]  ";
		
		
		// check whether the file exists beforehand, if yes use randomvar in front of filename
		srand();
		$randvar =  mt_rand(1,1000000);
		settype($randvar,"string");
		
$extension=explode(".",$realname);
$newfilename = dirname($_SERVER["SCRIPT_FILENAME"])."/uploadedimages/" . $randvar.".".$extension[count($extension)-1];// str_replace(" ","_",$realname);
//echo $newfilename;
$shortfname = $randvar.".".$extension[count($extension)-1];// . str_replace(" ","_",$realname);      

		while ( file_exists($newfilename) != FALSE )
		{
		$randvar =  mt_rand(1,100000);
		settype($randvar,"string");
$newfilename = dirname($_SERVER["SCRIPT_FILENAME"])."/uploadedimages/" . $randvar.".".$extension[count($extension)-1];// str_replace(" ","_",$realname);
$shortfname =  $randvar.".".$extension[count($extension)-1];// str_replace(" ","_",$realname);
		}
//////////////////////
		copy($_FILES['userfile']['tmp_name'], $newfilename);
		
		//=============================if insertion = yes
		if($insert=="yes")
		{
		if(!get_magic_quotes_gpc())
			$url=str_replace("$","\$",addslashes($shortfname));
		else
			$url=str_replace("$","\$",$shortfname);
			
		$pid=$_REQUEST["pid"];
		$num=$_REQUEST["num"];
		mysql_query("Insert into `b2b_product_images` ( sb_offer_id, sb_img_url) VALUES ( $pid,'$url')");
			
			if($config["sb_image_magik"]=="enable")
			{
			$size_str=$config["sb_th_width"] . "x" . $config["sb_th_width"];
			$size_str2=$config["sb_th_width2"] . "x" . $config["sb_th_width2"];
			$path1="uploadedimages" . '/' . $url;
			$path2="thumbs1" . '/' . $url;
			$path3="thumbs2" . '/' . $url;
				if($config["sb_water_marking"]=="enable")
				{
				exec("composite -dissolve 20 images/watermark.gif $path1 $path1");
				}
				exec("convert $path1 -resize $size_str $path2");
				exec("convert $path1 -resize $size_str2 $path3");
			}

		}
		
}// Else fr more than 60k

} 
else 
{	
$mess="Some Error Occurred! Please Try Again";
}
	header ("Location:"."view_images_product.php?sb_id=$pid&msg=".urlencode($mess));
	die();



[b]upload image.php[/b]

--------------------------------------------------

include_once "db.php";

$config=mysql_fetch_array(mysql_query("select * from b2b_config"));
		$pid=$_REQUEST["pid"];
		$num=$_REQUEST["num"];

if (is_uploaded_file($_FILES['userfile']['tmp_name'])) 
{
	$realname = $_FILES['userfile']['name'];
	if ($_FILES['userfile']['size']>($config["sb_image_size"]))
	{
	$mess="Uploaded files must be less than ".($config["sb_image_size"]/1000)."k. Please try again";
	}
	elseif($_FILES['userfile']['size']<=0)
	{
	$mess="File could not be uploaded. Please try again";
	}
	else
	{

//	echo $realname . ", size: ". $_FILES['userfile']['size'] . " [ ";
	$insert="no";
	switch($_FILES['userfile']['error'])
	{ case 0: $mess = "Image uploaded successfully"; $insert="yes";	  break;
	  case 1:
	  case 2: $mess = "Error : File size more than maximum size allowed by server";break;
	  case 3: $mess = "Error : File partially uploaded"; break;
	  case 4: $mess = "Error : No File Uploaded";
	  break;
	}
//	echo $mess . " ]  ";
		      
		
		// check whether the file exists beforehand, if yes use randomvar in front of filename
		srand();
		$randvar =  mt_rand(1,1000000);
		settype($randvar,"string");
		
$extension=explode(".",$realname);
$newfilename = dirname($_SERVER["SCRIPT_FILENAME"])."/uploadedimages/" . $randvar.".".$extension[count($extension)-1];// str_replace(" ","_",$realname);
//echo $newfilename;
$shortfname = $randvar.".".$extension[count($extension)-1];// . str_replace(" ","_",$realname);

		while ( file_exists($newfilename) != FALSE )
		{
		$randvar =  mt_rand(1,100000);
		settype($randvar,"string");
$newfilename = dirname($_SERVER["SCRIPT_FILENAME"])."/uploadedimages/" . $randvar.".".$extension[count($extension)-1];// str_replace(" ","_",$realname);
$shortfname =  $randvar.".".$extension[count($extension)-1];// str_replace(" ","_",$realname);
		}
//////////////////////
		copy($_FILES['userfile']['tmp_name'], $newfilename);
		
		//=============================if insertion = yes
		if($insert=="yes")
		{
		if(!get_magic_quotes_gpc())
			$url=str_replace("$","\$",addslashes($shortfname));
		else
			$url=str_replace("$","\$",$shortfname);
			
		$pid=$_REQUEST["pid"];
		$num=$_REQUEST["num"];
		mysql_query("Insert into `b2b_offer_images` ( sb_offer_id, sb_img_url) VALUES ( $pid,'$url')");
		
			if($config["sb_image_magik"]=="enable")
			{
			$size_str=$config["sb_th_width"] . "x" . $config["sb_th_width"];
			$size_str2=$config["sb_th_width2"] . "x" . $config["sb_th_width2"];
			$path1="uploadedimages" . '/' . $url;
			$path2="thumbs1" . '/' . $url;
			$path3="thumbs2" . '/' . $url;
				if($config["sb_water_marking"]=="enable")
				{
				exec("composite -dissolve 20 images/watermark.gif $path1 $path1");
				}
				exec("convert $path1 -resize $size_str $path2");
				exec("convert $path1 -resize $size_str2 $path3");
			}

		}
		
}// Else fr more than 60k

} 
else 
{	
$mess="Some Error Occurred! Please Try Again";
}
	header ("Location:"."view_images.php?sb_id=$pid&msg=".urlencode($mess));
	die();
-


feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]