Jump to content

NEWS ADD


NONAME_2

Recommended Posts

Hi all, i have a form for add-/edit- news.

my fields are :id postdate title newstxt formember preimg img1 img2 img3 authr.

i store (modified by concat date)names of news images in table and upload theme in folder /dir/newsimg.

i want my images in jpg/gif format and for preimage (103*103 pixel & <5KB) and for img1,2,3 (width:650 pixel & <50KB ).

Here is my (multipart)form:

<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>"  enctype="multipart/form-data">
		<div><input id="post_title" type="text" size="30" tabindex="1" value="news title" /></div>
		<textarea cols="80" rows="10"></textarea>
		<div >
			<h3>Just For Members:</h3>
			<ul>
			<li>
                <label><input type="checkbox" name="chbox"  />yes</label></li>
			</ul><BR/>
                <ul>
                <h4>news pics</h4>
                <li><p>preimg pic must be 103*103 pixel and maxsize <5kb.
                </p></li>
                <li><p>
                for image1,image2,image3 weightsize must ebe 650pixel and maxsize mustbe <50 kb.
                </p></li>
                <li>
                <INPUT TYPE=file NAME="preimg" size=20 accept="image/jpeg,image/gif">
                </li>
                <li><INPUT TYPE=file NAME="image1" size=20 accept="image/jpeg,image/gif">
                </li>
                <li><INPUT TYPE=file NAME="image2" size=20 accept="image/jpeg,image/gif">
                </li>
                <li><INPUT TYPE=file NAME="image3" size=20 accept="image/jpeg,image/gif">
                </li>
                </ul>
			<p>
			<input type="submit" value="preview" />
			<input type="submit" value="save" />
			</p>
		</div>
		</form>

in INSERT and for TEST MY IMAGES what should i add?

my php code is :

  include_once '../../config.inc.php';
  if (!include '../autorization.php')
  {
    echo 'Access denied!';
    exit ();
  }

if ($_POST['submit'])
  {
    $SQL = 'INSERT INTO news VALUES(?:for images);
    if (!(mysql_query ($SQL)))
    {
      exit ('Can\'t PUBLISH news!');
      ;
    }

    if ($_FILES['logo']['name'])
    {
      if (copy ($_FILES['preimg']['tmp_name'], $documentroot . ('' . ' /dir/newsimg/' . NOW() . '.') . substr ($_FILES['preimg']['type'], 6)))
      {
        unlink ($_FILES['logo']['tmp_name']);
      }
    }

    if ($_FILES['image1']['name'])
    {
      if (copy ($_FILES['image1']['tmp_name'], $documentroot . ('' . ' /dir/newsimg/' . NOW() . '.') . substr ($_FILES['image1']['type'], 6)))
      {
        unlink ($_FILES['image1']['tmp_name']);
      }
    }

    if ($_FILES['image2']['name'])
    {
      if (copy ($_FILES['image2']['tmp_name'], $documentroot . ('' . ' /dir/newsimg/' . NOW() . '.') . substr ($_FILES['image2']['type'], 6)))
      {
        unlink ($_FILES['image2']['tmp_name']);
      }
    }

    if ($_FILES['image3']['name'])
    {
      if (copy ($_FILES['image3']['tmp_name'], $documentroot . ('' . ' /dir/newsimg/' . NOW(). '.') . substr ($_FILES['image3']['type'], 6)))
      {
        unlink ($_FILES['image3']['tmp_name']);
      }
    }
  }

TNX.

Link to comment
https://forums.phpfreaks.com/topic/225315-news-add/
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.