function getExtension($str) {
$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}
define ("MAX_SIZE","2000");
if( isset($_FILES['file_upload']))
{
$errors=0;
$image=$_FILES['file_upload']['name'];
if ($image)
{
$filename = stripslashes($_FILES['file_upload']['name']);
$extension = getExtension($filename);
$extension = strtolower($extension);
if (($extension != "jpg") && ($extension != "bmp") && ($extension != "png") && ($extension != "gif"))
{
echo '<h1>Unknown extension!</h1>';
$errors=1;
}
else
{
$size=filesize($_FILES['file_upload']['tmp_name']);
if ($size > MAX_SIZE*1024)
{
echo '<h1>You have exceeded the size limit!</h1>';
$errors=1;
}
$random_name=md5(uniqid(mt_rand(), true)).'.'.$extension;
$from=$_FILES['file_upload']['tmp_name'];
$newname='"temp_images/'.$random_name.'"';
rename($from, $newname); Problm is here?????
//move_uploaded_file($from, $newname); Even tried this
}
}
}
I dont know why images are not moving in temp_images folder..Can anybody help me.Thanks in advance.
Edit:
HTML FORM:
<form name="form_upload" action="<?=$PHP_SELF?>" method="post" enctype="multipart/form-data">
<table class='nryo_modal_div_table' align='center'>
<tr>
<td align='left' class='response_color_ok'>
Select File:
</td> </tr> <tr>