php 이미지 업로드 용량제한

pcs4820의 이미지

php 로 이미지업로드시 용량을 제한하도록하려는데 잘안되네요.. 조언 부탁드리겠습니다...

--pic_upload.php--

<?php
//..mysql 부분만 생략...
if($upfile_name)
	{
		$checker = 0;
		$ext = substr(strrchr($upfile_name,"."),1);
		$ext = strtolower($ext);
		echo $ext."</br>";
		if (!($ext != "jpg"||$ext != "png"||$ext != "jpeg"||$ext != "gif"))
		{
			echo "해당 파일은 이미지가 아닙니다.</br>The file is not an image.";
			$checker= 1;
		}
		if ($_FILES[$upfile_name]["size"] > 5242880)
		{
			echo "해당 파일은 5MB를 초과합니다.</br>The file exceed 5mb";
			$checker= 1;
		}
		echo $original_name;
		if($checker==0){
		$original_name=$upfile_name;
		$upfile_name=date('YmdHis')."_".$upfile_name;
		$image = "/home/Sonogong/public_html/imgallery/Images/".$upfile_name;
		copy($upfile, $image);
		unlink($upfile);
		$qry = "insert into pic (num, title, file_name) values('','$title', '$upfile_name');";
		$res = mysql_query($qry, $connect);
		if($res)
		{
?>
			<table align=center> <?=$upfile_name?> 업로드 완료 </table>
<?
		}
		else
		{
?>
			<table align=center> 데이터 베이스 에러 </table>
<?
		}
	}
	else
	{
?>
		<table align=center> 이미지 업로드 실패 </table>
<?
	}
	}
	echo "<meta http-equiv='Refresh' content='1; URL=gal.php'>";
?>

-------------------------
저곳에서 어떻게 용량을 제한해야될지 모르겠네요
checker는 임시로만 저렇게 해둔거니 무시해주세요
red10won의 이미지

phpinfo()하면

post max size수정하시면 될겁니다^^

hiseob의 이미지

php.ini 에서 post max 하고 upload max 설정 하셔야 되구요, 저런식으로 체크하면 파일 업로드가 끝난다음 체크했던가 그랬던 기억이 나네요.

pcs4820의 이미지

제가 호스팅을 받아쓰는입장이라 그런건 수정할수없는거같네요, 다른방법 없을까요?

이응준의 이미지

.htaccess 파일에 설정하는 방법도 있습니다.

<IfModule mod_php5.c>
  php_value post_max_size 10M
  php_value upload_max_filesize 5M
</IfModule>

http://php.net/manual/en/configuration.changes.php

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.