Jump to content

urgent - problem with image upload script should be simple for someone!


misstwist

Recommended Posts

HI guys, i feel like a real loser asking this as i've done this may-a-time in the past (all be it a number of years ago) the rest of the site works fine and the last bit i'm trying to do is to get an image to upload, basicaly i have a simple add/edit/delete page, and it does everything it should - except laod the images, all the code i have done does is hard cropy the root directory i put in as a varible. i'd really really appricate a solotuion (FYI the form field and the DB field is called 'image1' (image 2 and 3 i'll add once i get image1 working)) here's the slice of code i'm working on

 

  if($mode=="add") {

 

 

 

//copy ($_FILES['image1']['tmp_name'], "./images".$_FILES['image1']['name']); 

$uploaddir = "/home/scootnz/public_html/images"; // Wherethe files to upload to

copy($_FILES['image1']['tmp_name'],$uploaddir.$_FILES['image1']['name']);

$image1 = $uploaddir.$_FILES['image1']['name'];

 

 

$Make=$_POST["Make"];

$Model=$_POST["Model"];

$EngineType=$_POST["EngineType"];

$EngineSize=$_POST["EngineSize"];

$Speed=$_POST["Speed"];

$Wheels=$_POST["Wheels"];

$Price=$_POST["Price"];

$Kilometres=$_POST["Kilometres"];

$Year=$_POST["Year"];

$Brakes=$_POST["Brakes"];

$image2=$_POST["image2"];

$image3=$_POST["image3"];

$ShortDes=$_POST["ShortDes"];

$LongDes=$_POST["LongDes"];

$sql="insert into bikes(Make,Model,EngineType,EngineSize,Speed,Wheels,Price,Kilometres,Year,Brakes,image1,image2,image3,ShortDes,LongDes) values('$Make','$Model','$EngineType','$EngineSize','$Speed','$Wheels','$Price','$Kilometres','$Year','$Brakes','$image1','$image2','$image3','$ShortDes','$LongDes')";

 

 

$result=mysql_query($sql,$connection) or die(mysql_error());

 

 

header("location: indexadmin.php");}

 

Thank guys in advance for your help!!

Link to comment
Share on other sites

ok here is the form:

 

 

  <form name="form1" method="post" action="formsubmit.php?mode=add">

       

        <br>

 

    <TABLE width="75%" align="center" class="imagebox55">

          <TR>

            <TD colspan="2"><P class="header" align="center"><b>Upload New Scooter </b></P><p class="menu" align="right">*required fields</p></TD>

          </TR>

                  <TR>

            <TD><p class="normal2">Make*</p></TD>

            <TD> <select name="Make">

                <option value="Vespa">Vespa</option>

                <option value="Piaggio">Piaggio</option>

                <option value="TGB">TGB</option>

                <option value="Peagout">Peagout</option>

              </select></TD>

          </TR>

                    <tr>

            <td height="37"> <p class="normal2">Model*</p></td>

            <td><INPUT TYPE="text" NAME="Model"></td>

          </tr>

          <tr>

            <td><p class="normal2">Engine Size*</p></td>

            <td><INPUT TYPE="text" NAME="EngineSize"></td>

          </tr>

          <tr>

  <tr>

            <td><p class="normal2">Engine Type*</p></td>

            <td><input type="text" name="EngineType"></td>

          </tr>

          <tr>

  <tr>

            <td><p class="normal2">Speed*</p></td>

            <td><INPUT TYPE="text" NAME="Speed"></td>

          </tr>

          <tr>

  <tr>

            <td><p class="normal2">Wheels</p></td>

            <td><INPUT TYPE="text" NAME="Wheels"></td>

          </tr>

          <tr>

  <tr>

            <td><p class="normal2">Brakes</p></td>

            <td><INPUT TYPE="text" NAME="Brakes"></td>

          </tr>

    <tr>

            <td><p class="normal2">Year</p></td>

            <td><INPUT TYPE="text" NAME="Year"></td>

          </tr>  <tr>

            <td><p class="normal2">Kilometres</p></td>

            <td width=81%><INPUT TYPE="text" NAME="Kilometres"></td>

          </tr>

    <tr>

            <td><br><br><br><p class="normal2">Image 1</p></td>

            <td><p class="menu">Please insure images are 300x300 pixels</p><br><input type="file" name="image1" size="30"></td>

          </tr>

    <tr>

            <td><p class="normal2">Image 2</p></td>

            <td><input type="file" name="image2" size="30"></td>

          </tr>

    <tr>

            <td><p class="normal2">Image 3</p></td>

            <td><input type="file" name="image3" size="30"></td>

          </tr>

          <tr>

            <td><p class="normal2">Short Description - up to 100 Characters</p></td>

            <td><textarea name="ShortDes" cols="50" rows="2"></textarea></td>

          </tr>

  <tr>

            <td><p class="normal2">Details - up to 250 Characters</p></td>

            <td><textarea name="LongDes" cols="50" rows="4"></textarea></td>

          </tr>   

            <td><p class="normal2">Price (NZD)$*</p></td>

            <td><INPUT TYPE="text" NAME="Price" size="7"></td>

          </tr>

   

        </TABLE>

<input type="submit" name="submit2" value="Save Data" class="header">

        <INPUT TYPE="RESET" VALUE="Reset">

      </FORM>

 

 

 

 

 

 

 

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.