Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Error in image file upload using dreamweaver

Participant ,
Feb 16, 2014 Feb 16, 2014

Greeting to you all!

Please I need you PRO help. My case seem similar to some of the ones I have seen but my code is completely different.

I wrote this code below using PHP in Dreamweaver and its used to upload images to MySQl database. Now when I upload about 6 images, it shows File Uploaded Successfully. But if I try to upload any thing below 6 images, it will refuse to upload and will echo Upload Failed.

<?php

if(isset($_POST['submit']))

{

          $projid=$_POST['projid'];

          $projname=$_POST['projname'];

 

          $name=basename($_FILES['file_upload']['name']);

          $t_name=$_FILES['file_upload']['tmp_name'];

          $dir='upload';

          if(move_uploaded_file($t_name,$dir."/".$name))

 

          $nameone=basename($_FILES['file_uploadone']['name']);

          $t_name=$_FILES['file_uploadone']['tmp_name'];

          $dir='upload1';

          if(move_uploaded_file($t_name,$dir."/".$name))

 

          $nametwo=basename($_FILES['file_uploadtwo']['name']);

          $t_name=$_FILES['file_uploadtwo']['tmp_name'];

          $dir='upload2';

 

          if(move_uploaded_file($t_name,$dir."/".$name))

          $namethree=basename($_FILES['file_uploadthree']['name']);

          $t_name=$_FILES['file_uploadthree']['tmp_name'];

          $dir='upload3';

 

          if(move_uploaded_file($t_name,$dir."/".$name))

          $namefour=basename($_FILES['file_uploadfour']['name']);

          $t_name=$_FILES['file_uploadfour']['tmp_name'];

          $dir='upload4';

          if(move_uploaded_file($t_name,$dir."/".$name))

 

          $namefive=basename($_FILES['file_uploadfive']['name']);

          $t_name=$_FILES['file_uploadfive']['tmp_name'];

          $dir='upload5';

          if(move_uploaded_file($t_name,$dir."/".$name))

          {

                    mysql_select_db ($database_ProjMonEva,$ProjMonEva);

                    $qur="insert into tbl_images (imageid, projid, projname, name, path, nameone, pathone, nametwo, pathtwo, namethree, paththree, namefour, pathfour, namefive, pathfive) values ('','$projid','$projname','$name','upload/$name','$nameone','upload/$nameone','$nametwo','upload/$nametwo','$namethree','upload/$namethree','$namefour','upload/$namefour','$namefive','upload/$namefive')";

                    $res=mysql_query($qur,$ProjMonEva);

                    echo 'File uploaded successful';

          }

          else

          {

                    echo 'upload failed!';

          }

}

?>

I see the problem to come from the echo but I am stock and dont know how to correct it. Can any one please help me.

Thank you in advance Mike

TOPICS
Server side applications
2.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Participant , Feb 17, 2014 Feb 17, 2014

Hi Bregent,

Do you mean like this

<?php

if(isset($_POST['submit']))

{

          $projid=$_POST['projid'];

          $projname=$_POST['projname'];

          $name=basename($_FILES['file_upload']['name']);

          $t_name=$_FILES['file_upload']['tmp_name'];

          $dir='upload';

          if(move_uploaded_file($t_name,$dir."/".$name))

          $nameone=basename($_FILES['file_uploadone']['name']);

          $t_name=$_FILES['file_uploadone']['tmp_name'];

          $dir='upload1';

          if(move_uploaded_

...
Translate
LEGEND ,
Feb 16, 2014 Feb 16, 2014

You're not using curly braces with your IF statement, so only the first line after the statement will be executing conditionally. The other lines will be executed unconditionally. Wrap all statement you want to group with curly braces.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 17, 2014 Feb 17, 2014

Hi Bregent,

Do you mean like this

<?php

if(isset($_POST['submit']))

{

          $projid=$_POST['projid'];

          $projname=$_POST['projname'];

          $name=basename($_FILES['file_upload']['name']);

          $t_name=$_FILES['file_upload']['tmp_name'];

          $dir='upload';

          if(move_uploaded_file($t_name,$dir."/".$name))

          $nameone=basename($_FILES['file_uploadone']['name']);

          $t_name=$_FILES['file_uploadone']['tmp_name'];

          $dir='upload1';

          if(move_uploaded_file($t_name,$dir."/".$name))

          $nametwo=basename($_FILES['file_uploadtwo']['name']);

          $t_name=$_FILES['file_uploadtwo']['tmp_name'];

          $dir='upload2';

          if(move_uploaded_file($t_name,$dir."/".$name))

          $namethree=basename($_FILES['file_uploadthree']['name']);

          $t_name=$_FILES['file_uploadthree']['tmp_name'];

          $dir='upload3';

          if(move_uploaded_file($t_name,$dir."/".$name))

          $namefour=basename($_FILES['file_uploadfour']['name']);

          $t_name=$_FILES['file_uploadfour']['tmp_name'];

          $dir='upload4';

          if(move_uploaded_file($t_name,$dir."/".$name))

          $namefive=basename($_FILES['file_uploadfive']['name']);

          $t_name=$_FILES['file_uploadfive']['tmp_name'];

          $dir='upload5';

          if(move_uploaded_file($t_name,$dir."/".$name))

         

                    mysql_select_db ($database_ProjMonEva,$ProjMonEva);

                    $qur="insert into tbl_images (imageid, projid, projname, name, path, nameone, pathone, nametwo, pathtwo, namethree, paththree, namefour, pathfour, namefive, pathfive) values ('','$projid','$projname','$name','upload/$name','$nameone','upload/$ nameone','$nametwo','upload/$nametwo','$namethree','upload/$namethree' ,'$namefour','upload/$namefour','$namefive','upload/$namefive')";

                    $res=mysql_query($qur,$ProjMonEva);

                    echo 'File uploaded successful';

        

          else

          {

                    echo 'upload failed!';

          }

}

?>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 17, 2014 Feb 17, 2014

>Do you mean like this

>    if(move_uploaded_file($t_name,$dir."/".$name))

>

>          $nameone=basename($_FILES['file_uploadone']['name']);

>          $t_name=$_FILES['file_uploadone']['tmp_name'];

>          $dir='upload1';

No, that's the same as before. In php as well as nearly all other programming languages, you use an IF statement to test a condition and then execute statements if that condition is true. IF statements use a grouping operator to group statements together than you want to execute. In PHP, the operator are the curly braces {}. You are allowed to not use the braces, but in that case only the first statement following the IF is executed conditionally.

The way you have it now, the line "$nameone=basename($_FILES['file_uploadone']['name']);" will only execute if the IF condition is true, but the other two lines:

$t_name=$_FILES['file_uploadone']['tmp_name'];

$dir='upload1';

will execute regardless of the IF statement - those lines are not associated with it in any way. So you need to use the group operator:

    if(move_uploaded_file($t_name,$dir."/".$name)){

          $nameone=basename($_FILES['file_uploadone']['name']);

          $t_name=$_FILES['file_uploadone']['tmp_name'];

          $dir='upload1';

  }

I would strongly urge you to get a book on basic programming to learn some of these fundamental rules or you will continue to struggle.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 18, 2014 Feb 18, 2014
LATEST

Hi Bregent,

I have been able to resolve the issue. I modified the code this way: This I believe will help those having the same issues.

These is how I was able to achieve it.

1. I divided the code into two parts called addnew.php and addnewproject.php.

The addnewproject.php as seen below will call the addnew.php when the submit button on addnewproject.php is clicked

<form action="addnew.php" method="POST" id="Add New Project" enctype="multipart/form-data">

      <div align="center">

        <table width="600" border="0" cellspacing="0" cellpadding="0">

          <tr>

            <td id="formcells4"><strong id="subheaders">Core Details</strong></td>

            <td></td>

          </tr>

          <tr>

            <td id="dates">*Code (Eg. 2104/12/AB23):<br />

              <label for="projcode"></label>

              <span id="sprytextfield1">

              <input type="text" name="projcode" id="projcode2" />

            <span class="textfieldRequiredMsg">A value is required.</span></span><br /></td>

            <td></td>

          </tr>

          <tr>

            <td colspan="2" id="dates">Project Name:

              <label for="projname3"></label>

              <span id="sprytextfield2">

              <input type="text" name="projname" id="projname3" />

              <span class="textfieldRequiredMsg">A value is required.</span></span></td>

          </tr>

          <tr>

            <td colspan="2" id="dates">Project Description:<span id="description"><br />

              <label for="projdesc"></label>

              <span id="txt_projdesc">

                <textarea name="projdesc" id="projdesc" cols="70" rows="8"></textarea>

                <span class="textareaRequiredMsg">A value is required.</span></span></span></td>

          </tr>

          <tr>

            <td id="formcells"><p id="dates">*Date Entered: <em>YYYY/MM/DD</em><span id="year">

              <label for="projappdate"><br />

              </label>

              <span id="txt_dateproapp">

                <input type="text" name="projappdate" id="projappdate" />

                <span class="textfieldRequiredMsg">A value is required.</span></span></span></p></td>

            <td id="formcells"><p id="dates">*Project LGA:<span id="txt_projlga">

              <label for="projlga"><br />

              </label>

              <span id="txt_lga">

                <select name="projlga" id="projlga">

                  <option value="1">.... Select from list ....</option>

                  <?php

do { 

?>

                  <option value="<?php echo $row_rsLGA['lga']?>"><?php echo $row_rsLGA['lga']?></option>

                  <?php

} while ($row_rsLGA = mysql_fetch_assoc($rsLGA));

  $rows = mysql_num_rows($rsLGA);

  if($rows > 0) {

      mysql_data_seek($rsLGA, 0);

            $row_rsLGA = mysql_fetch_assoc($rsLGA);

  }

?>

                </select>

            <span class="selectRequiredMsg">Please select an item.</span></span></span></p></td>

          </tr>

          <tr>

            <td id="formcells6"><p id="dates">*Project Community:<span id="txt_ojcommunity">

              <label for="projcommunity"><br />

              </label>

              <select name="projcommunity" id="projcommunity">

                <option value="1">.... Select from list ....</option>

                <?php

do { 

?>

                <option value="<?php echo $row_rsCommunity['community']?>"><?php echo $row_rsCommunity['community']?></option>

                <?php

} while ($row_rsCommunity = mysql_fetch_assoc($rsCommunity));

  $rows = mysql_num_rows($rsCommunity);

  if($rows > 0) {

      mysql_data_seek($rsCommunity, 0);

            $row_rsCommunity = mysql_fetch_assoc($rsCommunity);

  }

?>

              </select>

            </span></p></td>

            <td id="formcells6"><p id="dates">*Project State:<span id="txt_projstate"><br />

              <select name="projstate" id="projstate">

                <option value="1">.... Select from list ....</option>

                <?php

do { 

?>

                <option value="<?php echo $row_rsState['state']?>"><?php echo $row_rsState['state']?></option>

                <?php

} while ($row_rsState = mysql_fetch_assoc($rsState));

  $rows = mysql_num_rows($rsState);

  if($rows > 0) {

      mysql_data_seek($rsState, 0);

            $row_rsState = mysql_fetch_assoc($rsState);

  }

?>

              </select>

            </span></p></td>

          </tr>

          <tr>

            <td height="63" id="formcells8"><p id="dates">Project Cost:<span id="txt_projcost"><br />

              <label for="projcost"></label>

              <span id="txt_projectcost">

                <input name="projcost" type="text" id="projcost" />

                <span class="textfieldRequiredMsg">A value is required.</span></span></span></p></td>

            <td id="formcells"><p id="dates">*Project Type:<span id="txt_projtype"><br />

              <label for="projtype"></label>

              <select name="projtype" id="projtype">

                <option value="1">.... Select from list ....</option>

                <?php

do { 

?>

                <option value="<?php echo $row_rsType['projtypelist']?>"><?php echo $row_rsType['projtypelist']?></option>

                <?php

} while ($row_rsType = mysql_fetch_assoc($rsType));

  $rows = mysql_num_rows($rsType);

  if($rows > 0) {

      mysql_data_seek($rsType, 0);

            $row_rsType = mysql_fetch_assoc($rsType);

  }

?>

              </select>

            </span></p></td>

          </tr>

          <tr>

            <td colspan="2" id="formcells2"><p id="dates">Project Baseline Data:<span id="sprytextarea2"><br />

              <label for="projbaselinedata"></label>

              <textarea name="projbaselinedata" id="projbaselinedata" cols="70" rows="8"></textarea>

            </span></p></td>

          </tr>

          <tr>

            <td colspan="2" id="formcells3"><p id="dates">Expected Outcome Of Project:<span id="sprytextarea3"><br />

              <label for="Projexpoutcome"></label>

              <textarea name="Projexpoutcome" id="Projexpoutcome" cols="70" rows="8"></textarea>

            </span></p></td>

          </tr>

        </table>

        <table width="600" border="0" cellpadding="0" cellspacing="0" id="teamtable">

          <tr>

            <td colspan="2"><strong id="subheaders">Beneficiaries</strong></td>

          </tr>

          <tr>

            <td width="241"><p>Adult Men Beneficiaries: <span id="txt_adultmen">

              <label for="adultmen"><br />

              </label>

              <input name="adultmen" type="text" id="adultmen" />

            </span></p></td>

            <td width="259"><p>Adult Female Beneficiaries:<span id="txt_adultfem"><br />

              <label for="adultfem"></label>

              <input name="adultfem" type="text" id="adultfem" />

            </span></p></td>

          </tr>

          <tr>

            <td><p>Adult Children Beneficiaries:<span id="txt_totalchildren"><br />

              <label for="children"></label>

              <input name="totalchildren" type="text" id="totalchildren" />

            </span></p></td>

            <td><p>Total Beneficiaries:<span id="sprytextfield4"><br />

              <label for="totalben"></label>

              <input name="totalben" type="text" id="totalben" readonly="readonly" />

            </span></p></td>

          </tr>

          <tr>

            <td><p> </p></td>

            <td><p> </p></td>

          </tr>

          <tr>

            <td><strong id="subheaders">Project Team</strong></td>

            <td><p> </p></td>

          </tr>

          <tr>

            <td><p>*Project Team Leader:<span id="spryselect1"><br />

              <label for="projteamlead"></label>

              <select name="projteamlead" id="projteamlead">

                <option value="1">.... Select from list ....</option>

                <?php

do { 

?>

                <option value="<?php echo $row_rsProjectTeam['fullname']?>"><?php echo $row_rsProjectTeam['fullname']?></option>

                <?php

} while ($row_rsProjectTeam = mysql_fetch_assoc($rsProjectTeam));

  $rows = mysql_num_rows($rsProjectTeam);

  if($rows > 0) {

      mysql_data_seek($rsProjectTeam, 0);

            $row_rsProjectTeam = mysql_fetch_assoc($rsProjectTeam);

  }

?>

              </select>

            </span></p></td>

            <td><p>*Deputy Team Leader:<span id="spryselect2"><br />

              <label for="projteamlead"></label>

              <select name="projdepteamlead" id="projdepteamlead">

                <option value="1">.... Select from list ....</option>

                <?php

do { 

?>

                <option value="<?php echo $row_rsProjectTeam['fullname']?>"><?php echo $row_rsProjectTeam['fullname']?></option>

                <?php

} while ($row_rsProjectTeam = mysql_fetch_assoc($rsProjectTeam));

  $rows = mysql_num_rows($rsProjectTeam);

  if($rows > 0) {

      mysql_data_seek($rsProjectTeam, 0);

            $row_rsProjectTeam = mysql_fetch_assoc($rsProjectTeam);

  }

?>

              </select>

            </span></p></td>

          </tr>

          <tr>

            <td><p>*Project Officer:<span id="spryselect3"><br />

              <label for="projteamlead"></label>

              <select name="projofficer" id="projofficer">

                <option value="1">.... Select from list ....</option>

                <?php

do { 

?>

                <option value="<?php echo $row_rsProjectTeam['fullname']?>"><?php echo $row_rsProjectTeam['fullname']?></option>

                <?php

} while ($row_rsProjectTeam = mysql_fetch_assoc($rsProjectTeam));

  $rows = mysql_num_rows($rsProjectTeam);

  if($rows > 0) {

      mysql_data_seek($rsProjectTeam, 0);

            $row_rsProjectTeam = mysql_fetch_assoc($rsProjectTeam);

  }

?>

              </select>

            </span></p></td>

            <td><p>*Liason Officer:<span id="spryselect4"><br />

              <label for="projteamlead"></label>

              <select name="projliasonofficer" id="projliasonofficer">

                <option value="1">.... Select from list ....</option>

                <?php

do { 

?>

                <option value="<?php echo $row_rsProjectTeam['fullname']?>"><?php echo $row_rsProjectTeam['fullname']?></option>

                <?php

} while ($row_rsProjectTeam = mysql_fetch_assoc($rsProjectTeam));

  $rows = mysql_num_rows($rsProjectTeam);

  if($rows > 0) {

      mysql_data_seek($rsProjectTeam, 0);

            $row_rsProjectTeam = mysql_fetch_assoc($rsProjectTeam);

  }

?>

              </select>

            </span></p></td>

          </tr>

        </table>

        <table width="600" border="0" cellspacing="0" cellpadding="0">

          <tr>

            <td width="300" id="moredetails2"> </td>

            <td width="300"> </td>

          </tr>

          <tr id="moredetails">

            <td width="300" id="moredetails"><strong id="subheaders">Meeting Dates</strong></td>

            <td width="300"><strong id="subheaders">Other Dates</strong></td>

          </tr>

          <tr id="formrows">

            <td width="300" id="formrows"><p id="dates">*1st  Meeting Date: <em>YYYY/MM/DD</em><span id="txt_projmeeting1"><br />

              <input type="text" name="projmeeting1" id="projmeeting1" />

            </span></p></td>

            <td width="300" id="formrows"><p id="dates">*Project Start Date: <em id="formcells">YYYY/MM/DD</em><span id="txt_projstartdate">

              <label for="projstartdate"></label>

              <input type="text" name="projstartdate" id="projstartdate" />

              </span>

              <label for="projstartdate"></label>

            </p></td>

          </tr>

          <tr>

            <td width="300" id="formrows"><p id="dates">*2nd  Meeting Date: <em>YYYY/MM/DD</em><span id="txt_projmeeting2"><br />

              <input type="text" name="projmeeting2" id="projmeeting2" />

              </span>

              <label for="projteam2"></label>

              <label for="projmeeting2"></label>

            </p></td>

            <td width="300" id="formrows"><p id="dates">*Project End Date: <em>YYYY/MM/DD</em><span id="txt_projenddate"><br />

              <label for="projenddate2"></label>

              <input type="text" name="projenddate" id="projenddate" />

            </span></p></td>

          </tr>

          <tr>

            <td width="300" id="formrows"><p id="dates">*3rd Meeting Date: <em>YYYY/MM/DD</em><span id="txt_projmeeting3"><br />

              <input type="text" name="projmeeting3" id="projmeeting3" />

            </span></p></td>

            <td width="300" id="formrows"><p id="dates">*MoU Signing Date: <em id="formcells">YYYY/MM/DD</em><span id="txt_projmousigndate"><br />

              <label for="projmousigndate"></label>

              <input type="text" name="projmousigndate" id="projmousigndate" />

            </span></p></td>

          </tr>

          <tr>

            <td colspan="2" id="formrows2"><div align="center" id="notice"><img src="images/notice.jpg" width="501" height="73" /></div></td>

          </tr>

        </table>

      </div>

      <p align="center"></p>

      <p align="center" id="text">

        <input type="file" name="file_upload" />

        <input type="file" name="file_uploadone" />

        <input type="file" name="file_uploadtwo" />

      </p>

      <p align="center" id="text">

        <input type="file" name="file_uploadthree" />

        <input type="file" name="file_uploadfour" />

        <input type="file" name="file_uploadfive" />

      </p>

      <p align="center">

        <input type="submit" name="submit" value="Save & Submit"/>

      </p>

    </form>

The addnew.php will now execute and add the data and image file names and path to MySQL database and upload the images to their various locations. it will also check the image file size be sure its not more than 100kb and must really be an iamge with format .jpg, .png and .gif.

<?php

if(isset($_POST['submit']))

{

          $projcode=$_POST['projcode'];

          $projname=$_POST['projname'];

          $projname=$_POST['projname'];

          $projdesc=$_POST['projdesc'];

          $projappdate=$_POST['projappdate'];

          $projcommunity=$_POST['projcommunity'];

          $projlga=$_POST['projlga'];

          $projstate=$_POST['projstate'];

          $projcost=$_POST['projcost'];

          $projtype=$_POST['projtype'];

          $projbaselinedata=$_POST['projbaselinedata'];

          $Projexpoutcome=$_POST['Projexpoutcome'];

          $adultmen=$_POST['adultmen'];

          $adultfem=$_POST['adultfem'];

          $totalchildren=$_POST['totalchildren'];

          $totalben=$_POST['totalben'];

          $projteamlead=$_POST['projteamlead'];

          $projdepteamlead=$_POST['projdepteamlead'];

          $projofficer=$_POST['projofficer'];

          $projliasonofficer=$_POST['projliasonofficer'];

          $projmeeting1=$_POST['projmeeting1'];

          $projmeeting2=$_POST['projmeeting2'];

          $projmeeting3=$_POST['projmeeting3'];

          $projmousigndate=$_POST['projmousigndate'];

          $projstartdate=$_POST['projstartdate'];

          $projenddate=$_POST['projenddate'];

          $name=basename($_FILES['file_upload']['name']);

          $t_name=$_FILES['file_upload']['tmp_name'];

          $dir='imageone';

          // Validate uploaded image file

          if ( !preg_match( '/gif|png|jpeg/', $_FILES['file_upload']['type']) ) {

                       die('<p>Only browser compatible images allowed</p></body></html>');

          } else if ( $_FILES['file_upload']['size'] > 100000 )

                       die('<p>Sorry file too large</p></body></html>');

          if(move_uploaded_file($t_name,$dir."/".$name))

                    {

                    echo 'File 1 uploaded successfully....!';

          }

          else

          {

                    echo 'File 1 upload failed or was not submitted....!  ';

          }

          $nameone=basename($_FILES['file_uploadone']['name']);

          $t_name=$_FILES['file_uploadone']['tmp_name'];

          $dir='imagetwo';

          // Validate uploaded image file

          if ( !preg_match( '/gif|png|jpeg/', $_FILES['file_uploadone']['type']) ) {

                       die('<p>Only browser compatible images allowed</p></body></html>');

          } else if ( $_FILES['file_uploadone']['size'] > 100000 )

                       die('<p>Sorry file too large</p></body></html>');

          if(move_uploaded_file($t_name,$dir."/".$nameone))

                    {

                    echo 'File 2 was uploaded successfully....!';

          }

          else

          {

                    echo '...File 2 upload failed or was not submitted!  ';

          }

          $nametwo=basename($_FILES['file_uploadtwo']['name']);

          $t_name=$_FILES['file_uploadtwo']['tmp_name'];

          $dir='imagethree';

          // Validate uploaded image file

          if ( !preg_match( '/gif|png|jpeg/', $_FILES['file_uploadtwo']['type']) ) {

                       die('<p>Only browser compatible images allowed</p></body></html>');

          } else if ( $_FILES['file_uploadtwo']['size'] > 100000 )

                       die('<p>Sorry file too large</p></body></html>');

          if(move_uploaded_file($t_name,$dir."/".$nametwo))

                    {

                    echo 'File 3 uploaded successfully';

          }

          else

          {

                    echo '...File 3 upload failed or was not submitted!  ';

          }

          $namethree=basename($_FILES['file_uploadthree']['name']);

          $t_name=$_FILES['file_uploadthree']['tmp_name'];

          $dir='imagefour';

          // Validate uploaded image file

          if ( !preg_match( '/gif|png|jpeg/', $_FILES['file_uploadthree']['type']) ) {

                       die('<p>Only browser compatible images allowed</p></body></html>');

          } else if ( $_FILES['file_uploadthree']['size'] > 100000 )

                       die('<p>Sorry file too large</p></body></html>');

          if(move_uploaded_file($t_name,$dir."/".$namethree))

                    {

                    echo 'File 4 uploaded successfully';

          }

          else

          {

                    echo '...File 4 upload failed or was not submitted!  ';

          }

          $namefour=basename($_FILES['file_uploadfour']['name']);

          $t_name=$_FILES['file_uploadfour']['tmp_name'];

          $dir='imagefive';

          // Validate uploaded image file

          if ( !preg_match( '/gif|png|jpeg/', $_FILES['file_uploadfour']['type']) ) {

                       die('<p>Only browser compatible images allowed</p></body></html>');

          } else if ( $_FILES['file_uploadfour']['size'] > 100000 )

                       die('<p>Sorry file too large</p></body></html>');

          if(move_uploaded_file($t_name,$dir."/".$namefour))

                    {

                    echo 'File 5 uploaded successfully';

          }

          else

          {

                    echo '...File 5 upload failed or was not submitted!  ';

          }

          $namefive=basename($_FILES['file_uploadfive']['name']);

          $t_name=$_FILES['file_uploadfive']['tmp_name'];

          $dir='imagesix';

          // Validate uploaded image file

          if ( !preg_match( '/gif|png|jpeg/', $_FILES['file_uploadfive']['type']) ) {

                       die('<p>Only browser compatible images allowed</p></body></html>');

          } else if ( $_FILES['file_uploadfive']['size'] > 100000 )

                       die('<p>Sorry file too large</p></body></html>');

          if(move_uploaded_file($t_name,$dir."/".$namefive))

                    {

                    echo '    File 6 uploaded successfully';

          }

          else

          {

                    echo '....File 6 upload failed or was not submitted!  ';

          }

          mysql_select_db ($database_XXXXXXXX,$XXXXXXXX); where XXXXXXXX is my database connection details. Please change to yours.

                    $qur=("insert into tbl_projects (projid, projcode, projname, projdesc, projappdate, projcommunity, projlga, projstate, projcost, projtype, projbaselinedata, Projexpoutcome, adultmen, adultfem, totalchildren, totalben, projteamlead, projdepteamlead, projofficer, projliasonofficer, projmeeting1, projmeeting2, projmeeting3, projmousigndate, projstartdate, projenddate, name, path, nameone, pathone, nametwo, pathtwo, namethree, paththree, namefour, pathfour, namefive, pathfive) VALUES ('', '$projcode','$projname','$projdesc', '$projappdate', '$projcommunity', '$projlga', '$projstate', '$projcost', '$projtype', '$projbaselinedata', '$Projexpoutcome', '$adultmen', '$adultfem', '$totalchildren', '$totalben', '$projteamlead', '$projdepteamlead', '$projofficer', '$projliasonofficer', '$projmeeting1', '$projmeeting2', '$projmeeting3', '$projmousigndate', '$projstartdate', '$projenddate','$name','imageone/$name','$nameone','imagetwo/$nameone', '$nametwo', 'imagethree/$nametwo', '$namethree', 'imagefour/$namethree', '$namefour', 'imagefive/$namefour', '$namefive', 'imagesix/$namefive')");

                    $res=mysql_query($qur,$XXXXXXXX);

}

?>

Thank you. Hope this helps all those that are learning

Message was edited by: Prince Mike

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines