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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.