dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: Error Message: Your file is too big to upload!!!

  1. #1
    Join Date
    Jun 2011
    Location
    California
    Posts
    383

    Smile Error Message: Your file is too big to upload!!!

    Every time i try to upload an image file I get this error message. I basically can't upload anything anymore. I've made the images very small too and still nothing. =(


    [PHP]<?

    ob_start();

    //error_reporting(E_ALL);

    require("admin_utils.php");

    require("../includes/functions.php");



    if( isset( $_POST['mode'] ) && $_POST['mode']=='add' )

    disphtml("add_color_image();");

    else if( isset( $_POST['Submit'] ) && $_POST['Submit'] )

    {

    if($_POST['nextHiddenIndex']>$_POST['countHiddenIndex'])

    {

    $countImageIndex=$_POST['nextHiddenIndex'];

    }

    else

    {

    $countImageIndex=$_POST['countHiddenIndex'];

    }

    $upload_dir='../productImages/';

    //print_r($_FILES);

    //exit();

    for($i=0;$i<$countImageIndex;$i++){

    $temp_error = $_FILES['ph_image'.$i]['error'];

    if($temp_error == 0)

    {

    if($_FILES['ph_image'.$i]['name']!="")

    {

    $file_name = "";

    $file_name = time().'_'.$_SESSION['user_id'].'_'.$_FILES['ph_image'.$i]['name'];

    if(preg_match("/#/",$file_name))

    $file_name=preg_replace("/#/","",$file_name);

    $tmp_name = $_FILES['ph_image'.$i]['tmp_name'];

    $file_size = $_FILES['ph_image'.$i]['size'];

    $file_type = 'image';




    $sql = '';

    $check1 = fileUpload($upload_dir,$file_name,$tmp_name,$file_size,$file_type,$sql="");

    if($check1 != 0)//check1 returns 0 on success

    {

    $file_name='';

    $GLOBALS['err_msg']="Your file is too big to upload!!!";

    disphtml("add_color_image();");

    exit();

    //NA--->not available

    }

    //MakeThumbnail($upload_dir, $file_name ,500,'','big_thumbnail/big_thumb_');

    MakeThumbnail($upload_dir, $file_name ,100,'');



    $sql_gallery="insert into ".TABLE_PRODUCT_IMAGE_MASTER." set

    product_id='".$_POST['product_id']."',

    image_name='$file_name',

    is_active='Y'";

    $res=mysql_query($sql_gallery) or die("ERROR IN GALLERY IMAGE INSERT");

    }

    }

    else

    {

    $i--;

    $GLOBALS['err_msg']="Your last file is too big to upload!!!";

    disphtml("main();");

    exit();

    }

    }



    if($res>0)

    {

    $GLOBALS['err_msg']=$i;

    if($i>1)

    $GLOBALS['err_msg'].=" images";

    else

    $GLOBALS['err_msg'].=" image";

    $GLOBALS['err_msg'].=" successfully inserted ";

    }

    else

    $GLOBALS['err_msg']="Insert image not successful";



    disphtml("main();");

    }

    else if($_POST['mode']=='edit_default')

    {

    //$rsDefault=getValue(TABLE_PRODUCT_IMAGE_MASTER,$_POST['image_id'],'image_id','default_image');

    $rsProduct_id=getValue(TABLE_PRODUCT_IMAGE_MASTER,$_POST['image_id'],'image_id','product_id');

    $sqlDefaultZero="update ".TABLE_PRODUCT_IMAGE_MASTER." set default_image='0' where product_id='".$rsProduct_id."'";

    $rsDefaultZero=mysql_query($sqlDefaultZero);

    if($rsDefaultZero)

    {

    $sqlDefault="update ".TABLE_PRODUCT_IMAGE_MASTER." set default_image='1' where image_id='".$_POST['image_id']."'";

    $exeDefault=mysql_query($sqlDefault);

    }

    if($exeDefault)

    $GLOBALS['err_msg']="select default image successful";

    else

    $GLOBALS['err_msg']="select default image not successful";

    disphtml("main();");

    }

    else if($_POST['mode']=='delete')

    {

    $upload_dir='../productImages/';

    $image = trim(getValue(TABLE_PRODUCT_IMAGE_MASTER,$_POST['image_id'], 'image_id', 'image_name'));

    $unlink_image = $upload_dir.$image;

    if($image != "" && file_exists($unlink_image))

    {

    unlink($unlink_image);

    }



    //unlink big thumbnail image

    /*$unlink_big_thumb_image = $upload_dir."big_thumbnail/big_thumb_".$image;

    if($image !="" && file_exists($unlink_big_thumb_image))

    {

    unlink($unlink_big_thumb_image);

    }*/

    //unlink small thumnail image



    $thumb_image = 'thumb_'.$image;

    $unlink_thumb_image = $upload_dir."thumbnail/thumb_".$image;

    if($image !="" && file_exists($unlink_thumb_image))

    {

    unlink($unlink_thumb_image);

    }

    $qery=mysql_query("delete from ".TABLE_PRODUCT_IMAGE_MASTER." where image_id='".$_POST['image_id']."'");

    if($qery)

    $GLOBALS['err_msg']="Deletion successful";

    else

    $GLOBALS['err_msg']="Deletion not successful";

    disphtml("main();");

    }

    else

    disphtml("main();");

    function main()

    {

    $sqlProductImage="select * from ".TABLE_PRODUCT_IMAGE_MASTER." where product_id='".$_REQUEST['product_id']."'";

    $exeProductImage=mysql_query($sqlProductImage);

    $count=mysql_num_rows($exeProductImage);

    ?>

    <script language="JavaScript">

    function add_image()

    {

    document.frmGallery.mode.value='add';

    document.frmGallery.action="manageProductImage.php?<?=$_SERVER['QUERY_STRING']?>";

    document.frmGallery.submit();

    }

    function edit_default(record_id)

    {



    document.frmGallery.image_id.value=record_id;

    document.frmGallery.mode.value='edit_default';

    document.frmGallery.submit();

    }

    function delete_gallery(record_id)

    {

    var UserResp= window.confirm('Are you sure remove this image?');

    if(UserResp==true)

    {

    document.frmGallery.image_id.value=record_id;

    document.frmGallery.mode.value='delete';

    document.frmGallery.submit();

    }

    }

    </script>

    <form name="frmGallery" method="post" action="<?=$_SERVER['PHP_SELF']?>?<?=$_SERVER['QUERY_STRING']?>">

    <input type="hidden" name="mode">

    <input type="hidden" name="image_id">

    <input type="hidden" name="product_id" value="<?php if ( isset( $_REQUEST['product_id'] ) ) echo $_REQUEST['product_id']; ?>">

    <table width="99&#37;" align="center" style="BORDER: #DAE3F4 1px solid;" cellpadding="5" cellspacing="2">

    <tr class="TDHEAD" bgcolor="#799BE1" style="color:#ffffff">

    <td colspan="2" align="left">Product Image</td>

    </tr>

    <tr>

    <td align="center" class="ERR"><strong><?php if ( isset( $GLOBALS['err_msg'] ) ) echo $GLOBALS['err_msg']; ?></strong></td>

    <td align="right" width="25%" >

    <a href="manageProduct.php">

    <img src="images/left.png" border="0">

    </a>&nbsp;&nbsp;

    <a href="javascript:add_image();" title=" Add Socks Images">

    <img src="images/plus_icon.gif" border="0">

    </a>

    </td>

    </tr>

    <tr><td colspan="2">

    <table width="100%" border="0" cellspacing="0" cellpadding="0">

    <? if($count>0){ echo "<tr>";

    while($rsProductImage=mysql_fetch_array($exeProductImage)){

    if($col<=3)

    echo "<td valign='middle'>";

    else

    {

    echo "<tr><td valign='middle'>";$col=1;

    }

    if (file_exists("../productImages/".$rsProductImage['image_name'].""))

    {list($width, $height, $type, $attr)=getimagesize("../productImages/".$rsProductImage['image_name']."");

    ?>

    <div align="center"><a href="#" onClick="javascript:window.open('../largeImageShow.php?image_id=<?=$rsProductImage['image_id']?>','','width=<?=$width+50?>,height=<?=$height+80?>,top=150,resizable=yes,scrollbars=yes')"><img src="../productImages/thumbnail/thumb_<?=$rsProductImage['image_name']?>" border="0" title="Click on this image"></a><br> <a href="#" onClick="edit_default(<?=$rsProductImage['image_id']?>)" title="Select default"><? if($rsProductImage['default_image']==0) echo "<font color=\"#FF0000\">Default</font>"; else echo "<font color=\"green\">Default</font>";?></a>&nbsp;&nbsp;<a href="edit_prodect_images.php?image_id=<?=$rsProductImage['image_id']?>&product_id=<?=$_REQUEST['product_id']?>" title="Edit photo">Edit</a>&nbsp;&nbsp;<a href="#" onClick="javascript:delete_gallery(<?=$rsProductImage['image_id']?>);" title="Delete photo">Delete</a></div>

    <? }

    else

    {

    list($width, $height, $type, $attr)=getimagesize("../productImages/not_available.gif");

    ?>

    <div align="center"><a href="#" ><img src="../productImages/thumbnail/thumb_not_available.gif" border="0" title="Click on this image"></a><br> <a href="#" onClick="edit_default(<?=$rsProductImage['image_id']?>)" title="Select default"><? if($rsProductImage['default_image']==0) echo "<font color=\"#FF0000\">Default</font>"; else echo "<font color=\"green\">Default</font>";?></a>&nbsp;&nbsp;<a href="#" onClick="javascript:delete_gallery(<?=$rsProductImage['image_id']?>);" title="Delete photo">Delete</a></div>

    <? }

    ?>



    <? if($col<=3)

    {

    echo "</td>";$col++;

    }

    else

    echo "</td></tr>";

    }

    echo "</td></tr>";

    }

    else {

    ?>

    </table>

    </td></tr>

    <tr>

    <td align="center" colspan="2" class="smallred">No Image uploded</td>

    </tr>

    <? }?>

    </table>

    </form>

    <? }////////////// end of function add_color_image()?>

    Any help would be greatly appreciated.

  2. #2
    Join Date
    Jun 2011
    Location
    California
    Posts
    383

    Thumbs down I've gotten it to upload pictures now.

    But in the database (TABLE_PRODUCT_IMAGE_MASTER)the 'image_name' field (where the actual image file resides) is not injecting/populating.

  3. #3
    Join Date
    Jun 2011
    Location
    California
    Posts
    383

    Red face

    I'm stuck now on this error.


    Fatal error: Call to undefined function add_color_image() in /admin_utils.php(65) : eval()'d code on line 1



    I removed the add_color_image but I still get the error.

    Need help please.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles