note 50507 rejected from features.file-upload by irchtml
| From: | irchtml@php.net | Date: | Wed, 02 Mar 2005 15:22:46 +0000 |
| Subject: | note 50507 rejected from features.file-upload by irchtml | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-85789@lists.php.net to get a copy of this message | ||
Note Submitter: ansarka at rediffmail dot com
----
Hello sir's
I have written a code to upload gif and jpeg files but files after uploading the photo is not
clear also the image size is also increasing . Any one please help me
My code is given below
---------------------------------------
<form name="frmreg" method="POST" onSubmit="return validate()"
action="myupload.php" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="30000" >
<input type="file" name="up_file" size="43"
class="input">
-------------------------------
myupload.php
<?
if(!empty($_FILES["up_file"]))
{
$uploaddir = "../images/photos";// set this to wherever
// echo $uploaddir.$HTTP_POST_FILES["up_file"]["name"];
//echo $HTTP_POST_FILES["up_file"]["tmp_name"];
if ($_FILES["up_file"]["type"]=="image/pjpeg")
{
$a=$_FILES["up_file"]["name"];
$b=$user_id;
$fn1="$uploaddir/net_er".$b.".jpg";
$fn="$uploaddir/net_er".$b.".gif";
if(file_exists($fn))
{
unlink($fn);
}
if(file_exists($fn1))
{
unlink($fn1);
}
if ($_FILES["up_file"]["size"]>1024*60)
{
redirectto("uploadphoto_size_error.php");
}
else if (move_uploaded_file($_FILES["up_file"]["tmp_name"],
$uploaddir."/" . $_FILES["up_file"]["name"]))
{
rename("$uploaddir/".$a, "$uploaddir/net_er".$b.".jpg");
redirectto("member_home.php");
}
else
{
redirectto("upload_error.php");
}
}
else if($_FILES["up_file"]["type"]=="image/gif")
{
$a=$_FILES["up_file"]["name"];
$b=$user_id;
$fn1="$uploaddir/net_er".$b.".jpg";
$fn="$uploaddir/net_er".$b.".gif";
if(file_exists($fn))
{
unlink($fn);
}
if(file_exists($fn1))
{
unlink($fn1);
}
if ($_FILES["up_file"]["size"]>1024*60)
{
redirectto("uploadphoto_size_error.php");
}
else if (move_uploaded_file($_FILES["up_file"]["tmp_name"], $uploaddir .
$_FILES["up_file"]["name"]))
{
rename("$uploaddir".$a, "$uploaddir".$b.".gif");
redirectto("member_home.php");
}
else
{
redirectto("upload_error.php");
}
}
else
{ redirectto("uploadphoto_type_error.php");
}
}
else
{
redirectto("upload_error.php");
}
?>