Jump to content

Help with a simpel upload script that doesn't work


leeser

Recommended Posts

Hi guys, I really hope you can help me out.

I have got this upload script, the only problem is that it doesn't upload the files. The folder it should upload to is 777.

It insert a SQL entry as it should so I inly need the files to show up in my folder now

 

 

 

<?php

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

 

 

    $text = $_POST['titel'];

    mysql_connect("localhost", "m", "m") or die(mysql_error());

    mysql_select_db("madebylasse_dk") or die(mysql_error());

    mysql_query("INSERT INTO pixelbilleder (titel) VALUES ('$text')") OR DIE(mysql_error());

    $id = mysql_insert_id();

    $extension = 'jpg';

 

 

  for($i = 1; $i <= 2; $i++){

        if (move_uploaded_file($_FILES['minfil']['tmp_name'], '/customers/madebylasse.dk/madebylasse.dk/httpd.www/Billeder/' . $id . '-' . $i . '.jpg'))

{

            echo 'Fil: ' . $i . ' - Uploaded';

        }else{

            echo 'Fil: ' . $i . ' - Error';

        }

    }

}

else

{

?>

 

<form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">

    File 1: <input name="minfil[1]" type="file"><br />

  File 2: <input name="minfil[2]" type="file"><br />

    Titel: <input type="text" name="titel"><br />

 

    <input type="submit" name="upload" value="Upload fil">

</form>

 

<?

}

?>

You are not accessing the uploaded temp file correctly -

 

This -

$_FILES['minfil']['tmp_name']

 

should be -

$_FILES['minfil']['tmp_name'][$i]

 

Using full php error reporting when developing and debugging php code will help you find problems like this. Make sure that error_reporting is set to E_ALL and display_errors is set to ON in your php.ini (stop and start your web server to get any change made to php.ini to take effect) and make sure the php.ini that you are changing is the one php is using.

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.