Jump to content

upload picture


shamsuljewel

Recommended Posts

Yes I configure php.ini

and use $POST['userfile'] too.

$userfile = $_POST['userfile'];
if($userfile != "")
	{
		$err = 0;
		echo $userfile;
		if($userfile_type != "image/gif" && $userfile_type != "image/jpeg")
			{
				echo "<script language='javascript'>alert('Sorry!!! Pic type not Supported!!!');history.back(-1);</script>";
				$err=1;
			}
		else
			{
				$maxSize=4;
				$maxWidth=150;
				$maxHeight=150;
				list($width, $height, $imgType, $str)=getimagesize($userfile);

				if($height > $maxHeight || $width > $maxWidth)
					{
						echo "<script language='javascript'>alert('Dimension of Image Must not exceed $maxWidth X $maxHeight!!!');history.back(-1);</script>";
						$err=1;
					}
				else if($userfile_size > (1024*$maxSize))
					{
						echo "<script language='javascript'>alert('Sorry Pic Must not be bigger than $maxSize kb!!!');history.back(-1);</script>";
						$err=1;
					}
			}
			if(err==0)
			{
				echo "no error";
				//@move_uploaded_file($userfile, "pic/user_pic_ami.gif") or die("Could not upload!");
				//@copy($_FILES[userfile][tmpname],"pic/".$_FILES[userfile][mainname]) or die("Could not copy the file.");
				echo $row["id"];
				echo $userfile;
				if(!@move_uploaded_file($userfile, $pic="pic/user_pic_".$row["id"].".gif"))
					{
						echo "<script language='javascript'>alert('Sorry!!! File Cannot be Uploaded!!! all other information updated ');history.back(-1);</script>";
					}

			}
	}

Link to comment
https://forums.phpfreaks.com/topic/69542-upload-picture/#findComment-349439
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.