moving imge from one folder to another

images php coding issues or problems here.

Moderators: macek, egami, gesf

nehakarnatak
New php-forum User
New php-forum User
Posts: 11
Joined: Tue Feb 28, 2012 10:06 pm

moving imge from one folder to another

Postby nehakarnatak » Wed Sep 05, 2012 12:51 am

anyone please help me , how move an image from one folder to another folder using php coding


nehakarnatak
New php-forum User
New php-forum User
Posts: 11
Joined: Tue Feb 28, 2012 10:06 pm

Re: moving imge from one folder to another

Postby nehakarnatak » Wed Sep 05, 2012 1:52 am

got the ans

rename('/path1/old_filename', '/path2/new_filename');

pradeepcarya
New php-forum User
New php-forum User
Posts: 22
Joined: Mon Oct 24, 2011 10:10 am

Re: moving imge from one folder to another

Postby pradeepcarya » Wed Sep 05, 2012 3:26 am

echo "start 1" ;

$newfilename = "/crm/tmp/picname.jpg";
echo "starting if - ".$newfilename ;

//$n= $imgdir . $a;
//check for existing file
if (file_exists($newfilename))
{
echo $newfilename;
echo "im in if blck - ".$newfilename ;
}

praneha
New php-forum User
New php-forum User
Posts: 12
Joined: Wed Sep 05, 2012 2:13 pm

Re: moving imge from one folder to another

Postby praneha » Wed Sep 05, 2012 2:18 pm

did u get solution?

nehakarnatak
New php-forum User
New php-forum User
Posts: 11
Joined: Tue Feb 28, 2012 10:06 pm

Re: moving imge from one folder to another

Postby nehakarnatak » Wed Sep 05, 2012 8:22 pm

got the code but can not apply to my code

praneha
New php-forum User
New php-forum User
Posts: 12
Joined: Wed Sep 05, 2012 2:13 pm

Re: moving imge from one folder to another

Postby praneha » Wed Sep 05, 2012 11:01 pm

send me here pls

praneha
New php-forum User
New php-forum User
Posts: 12
Joined: Wed Sep 05, 2012 2:13 pm

Re: moving imge from one folder to another

Postby praneha » Wed Sep 05, 2012 11:14 pm

//$_SESSION['profile_id'] = TRIM($_POST['profile_id']) ;

$a = TRIM($_POST['profile_id']) ;
echo hye.$a;

$First_Name = $_SESSION['First_Name'];

$Last_Name = $_SESSION['Last_Name'];

//$a =$Profile_Id;

praneha
New php-forum User
New php-forum User
Posts: 12
Joined: Wed Sep 05, 2012 2:13 pm

Re: moving imge from one folder to another

Postby praneha » Wed Sep 05, 2012 11:27 pm

echo "start 1" ;
$newfilename = "/crm/tmp/50483400442c0";
echo "starting if - ".$newfilename ;

//check for existing file
if (file_exists($newfilename))
{
rename("/crm/tmp/50483400442c0","/crm/photograph/50483400442c01");
echo $newfilename;
echo "im in if blck - ".$newfilename ;
if (unlink($newfilename))
{
echo ("Error deleting $newfilename");
}
else
{
echo ("Deleted $newfilename");
}
}
else
{
echo "im in else blck out of if" ;
}

praneha
New php-forum User
New php-forum User
Posts: 12
Joined: Wed Sep 05, 2012 2:13 pm

Re: moving imge from one folder to another

Postby praneha » Wed Sep 05, 2012 11:33 pm

//code start
$image_tmpname = $_FILES['image_filename']["name"];
$imgdir ="/crm/tmp/";

$imgname = $imgdir.$image_tmpname;

echo "start 1" ;
//$newfilename = "/crm/tmp/50483400442c0";
$newfilename = $imgdir.$a;
echo "starting if - ".$newfilename ;

//check for existing file
if (file_exists($newfilename))
{
//rename("/crm/tmp/50483400442c0","/crm/photograph/50483400442c01");
rename($imgname,$newfilename);

echo $newfilename;
echo "im in if blck - ".$newfilename ;
if (unlink($newfilename))
{
echo ("Error deleting $newfilename");
}
else
{
echo ("Deleted $newfilename");
}
}
else
{
echo "im in else blck out of if" ;
}

praneha
New php-forum User
New php-forum User
Posts: 12
Joined: Wed Sep 05, 2012 2:13 pm

Re: moving imge from one folder to another

Postby praneha » Thu Sep 06, 2012 1:18 am

//code start
$image_tmpname = $_FILES['image_filename']["name"];
$imgdir ="/crm/tmp/";
$ext =".jpg";

$imgname = $imgdir.$image_tmpname;
echo "start 1" ;
echo "image name- ".$imgname ;
//$imgname = $imgdir.$image_tmpname.$ext;

//$newfilename = "/crm/tmp/50483400442c0";
$newfilename = $imgdir.$a.$ext;
echo "starting if - ".$newfilename ;

//check for existing file
if (file_exists($newfilename))
{
//rename("/crm/tmp/50483400442c0","/crm/photograph/50483400442c01");
rename($imgname,$newfilename);

echo $newfilename;
echo "im in if blck - ".$newfilename ;
if (unlink($newfilename))
{
echo ("Error deleting $newfilename");
}
else
{
echo ("Deleted $newfilename");
}
}
else
{
echo "im in else blck out of if" ;
}


Return to “PHP coding => Images”

Who is online

Users browsing this forum: No registered users and 2 guests