Mover imágenes después del envío

I have the following code : HTML :

<html>
 <head>
    <title>Inserare produse in baza de date</title>
    <style>
        table{
            border: 1px solid black;
        }
    </style>
 </head>
 <body>
    <div id="subForm" style="border:1px solid black;text-align:center;">
        <table><form action="addScript.php" methot="POST">
            <tr>
                <td>Produt name : </td><td><input type="text" name="name" id="name" /></td>
            </tr>
            <tr>
                <td>Product description : </td><td><textarea rows="5" cols="40" name="description" id="description"></textarea></td>
            </tr>
            <tr>
                <td>Price (USD $) : </td><td><input type="text" name="price" id="price" /></td>
            </tr>
            <tr>
                <td>Profile Picture : </td><td><input type="file" name="profilepic" id="profilepic" /></td>
            </tr>
            <tr>

                <td>Other pictures : </td><td>
                <div id="pictures" style="border:1px solid black;"><table>
                <tr><td>1</td><td><input type="file" id="pic1" name="pic1" /></td></tr>
                <tr><td>2</td><td><input type="file" id="pic2" name="pic2" /></td></tr>
                <tr><td>3</td><td><input type="file" id="pic3" name="pic3" /></td></tr>
                </table>
            </div>
            </td>
        </tr>
        <tr>
            <td></td><td><input type="submit" value="Add" /></td>
        </form>
    </div>
</html>

PHP

<?php
  //connect to database
    $username="user";
    $password="pass";
    $database="db";
    $con=mysqli_connect("localhost",$username,$password,$database);
  // Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
  //get info from form
  $name=$_POST['name'];
  $description=$_POST['description'];
  $price=$_POST['price'];
  $profilePic=$_FILES['profilepic'];
  $path="images/";

  //move picures in image/ folder and get their path
  $pic1=$_FILES['pic1']['name'];
  $pictmp=$_FILES['pic1']['tmp_name'];
  $moveResult=move_uploaded_file($pictmp, $path);

  $pic2=$_FILES['pic2']['name'];
  $pictmp=$_FILES['pic2']['tmp_name'];
  $moveResult=move_uploaded_file($pictmp, $path);

  $pic3=$_FILES['pic3']['name'];
  $pictmp=$_FILES['pic3']['tmp_name'];
  $moveResult=move_uploaded_file($pictmp, $path);

  $pic1Path=$path.$pic1;
  $pic2Path=$path.$pic2;
  $pic3Path=$path.$pic3;

//insert info in database
$sql="INSERT INTO products ( name, description, price, profile_pic, pic1, pic2, pic3)
  VALUES 
  ('$name','$description','$price',$profilePic','$pic1Path','$pic2Path','$pic3Path')";
  if(!mysqli_query($con,$sql)){
    die("ERROR".mysqli_error($con));
  }
  echo "1 product added";
  mysqli_close($con);


?>

And my database looks like this :

| ID | name | description | price | profile_pic | pic1 | pic2 | pic3|*

*pic comes from picture.

The problem is this : Every time I try to submit the form, I get this error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@domain.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

What have I done wrong?What am I missing?Is the PHP file wrong or what?

EDIT:

I found on the internet that I had set permissions to high. New I set it to 755 and I got rid of the error , but my script still doesn't work because nothing is echoed at the end.

¿Alguien tiene alguna idea?

preguntado el 05 de febrero de 14 a las 11:02

check your error log usually the log file is in /var/log/apache2/error.log or /var/log/httpd/error.log -

I found this in the log : [Wed Feb 05 14:41:23 2014] [error] [client mi IP] SoftException in Application.cpp:259: File "/home/domain/public_html/addScript.php" is writeable by group, referer: domain.com/addInDatabase.php -

I have permissions to both files set to 777 -

@Denny Bejan it is not a error of code error is server side -

Yes...I have edited my post and said that I don't get the error any more, but now I get back a blank page. -

1 Respuestas

Prueba esto ...

<form action="addScript.php" methot="POST" enctype="multipart/form-data">

Respondido 05 Feb 14, 11:02

this will ensure the file to be uploaded, otherwise no $_FILES array will be created for php. - Volkan Ulukut

Parece method está mal escrito como methot. - SupervivenciaMáquina

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.