$my_loci=$_SERVER['SERVER_NAME'];
$link1="http://".$my_loci."/forum/images" ;
if ($_FILES["fileToUpload"]["type"]=="image/jpeg" )
{
if ($my_option==1){
$pattern = "/.jpe?g/i";
$cleaned_base_name=preg_replace($pattern, "", $base_name);
rename($target_file, "../".$cleaned_base_name."_n".$number.".jpg");
$link2=$link1."/".$cleaned_base_name."_n".$number.".jpg";
} // option1
if ($my_option==2){
rename($target_file, "../n".$number.".jpg");
$link2=$link1."/n".$number.".jpg";
} // option=2
} // jpg
if ($_FILES["fileToUpload"]["type"]=="image/png" )
{
if ($my_option==1)
{
$pattern = "/.png/i";
$cleaned_base_name=preg_replace($pattern, "", $base_name);
rename($target_file, "../".$cleaned_base_name."_n".$number.".png");
$link2=$link1."/".$cleaned_base_name."_n".$number.".png";
} // option1
if ($my_option==2){
rename($target_file, "../n".$number.".png");
$link2=$link1."/n".$number.".png";
} // option2
} // png
if ($_FILES["fileToUpload"]["type"]=="image/gif" )
{
if ($my_option==1)
{
$pattern = "/.gif/i";
$cleaned_base_name=preg_replace($pattern, "", $base_name);
rename($target_file, "../".$cleaned_base_name."_n".$number.".gif");
$link2=$link1."/".$cleaned_base_name."_n".$number.".gif";
} // option1
if ($my_option==2){
rename($target_file, "../n".$number.".gif");
$link2=$link1."/n".$number.".gif";
} // option 2
} // gif
//================================
if ($_FILES["fileToUpload"]["type"]=="application/zip" )
{
if ($my_option==1){
$pattern = "/.zip/i";
$cleaned_base_name=preg_replace($pattern, "", $base_name);
rename($target_file, "../".$cleaned_base_name."_n".$number.".zip");
$link2=$link1."/".$cleaned_base_name."_n".$number.".zip";
} // option1
if ($my_option==2){
rename($target_file, "../n".$number.".zip");
$link2=$link1."/n".$number.".zip";
} // option=2
} // zip
//=============================
//=============================
if ($_FILES["fileToUpload"]["type"]=="application/pdf" )
{
if ($my_option==1){
$pattern = "/.pdf/i";
$cleaned_base_name=preg_replace($pattern, "", $base_name);
rename($target_file, "../".$cleaned_base_name."_n".$number.".pdf");
$link2=$link1."/".$cleaned_base_name."_n".$number.".pdf";
} // option1
if ($my_option==2){
rename($target_file, "../n".$number.".pdf");
$link2=$link1."/n".$number.".pdf";
} // option=2
} // zip
//======================
echo"<center>";
echo"<br>";
$d_type=$_FILES["fileToUpload"]["type"];
if ($d_type=="image/jpg" || $d_type=="image/png" || $d_type=="image/gif")
{
echo $link2;
echo"<div id='link_img'>";
echo"[Img]".$link2."[/Img]";
echo"</div>";
} // if image
else
{
echo"<div id='link_img'>";
echo $link2;
echo"</div>";
} // if not image
echo"<br>";
echo"<br>";