Hi
I'm supposed to make a site (webshop) for school and it has to be done by tomorrow. There aren't any problems APART FROM this one thing..
So there's a page that will display the things people can 'buy', but I don't just want to add them in the html etc.
So I made an adminCP where I should be able to add items.. (the image of the article is uploaded to /images/bestellingen - or atleast it SHOULD be) and the url is put in the database with the rest of the information..
Naam - prijs - beschrijving - afbeelding
(equals name - price - description - image)
It all works apart from the image uploading --> ftp.. (the url IS put into the database correctly..)
I always get the reply 'fout' as a result of the if... else...
And yes the CHMOD of the /images/bestellingen/ folder is put to 777
Here you have the code.
HTML:
HTML Code:
<table>
<form enctype="multipart/form-data" action="insert.php" method="post" >
<tr><td>Afbeelding:</td><td><input name="image" type="file"></td></tr>
<tr><td>Naam:</td><td><input name="naam" type="text" /></td></tr>
<tr><td>Prijs:</td><td><input name="prijs" type="text" /></td></tr>
<tr><td>Omschrijving:</td><td><textarea name="omschrijving" ></textarea></td></tr>
<tr><td></td><td><input value="Submit" type="submit"></td></tr>
</form>
</table>
Insert.php
PHP Code:
<?php $host="localhost"; $name = "correct"; $pass = "correct"; $dbname = "correct";
$dbi = mysql_connect($host, $name,$pass) or die("Kan niet verbinden met de database. Error :" . mysql_error()); mysql_select_db($dbname,$dbi);
$folder = "images/bestellingen/"; // folder where the images will be saved $file_name = base64_encode(rand().rand().rand()); // generate random name
$path_info = pathinfo($_FILES['image']['name']); // Find extension $file_extension = $path_info['extension']; // put extension in var $target = $folder . $file_name .".". $file_extension; // where and with which filename will it be saved $source = $_FILES['image']['tmp_name']; // uploaded file (I think that the failure is located here..) if(move_uploaded_file($source, $target)){ echo "afbeelding is geupload!"; } else { echo "fout"; } // Save file with new name on new location
$naam = $_POST['naam']; $prijs = $_POST['prijs']; $omschrijving = $_POST['omschrijving']; $query = "INSERT INTO bestellingen (naam,prijs,beschrijving,image) VALUES ('$naam','$prijs','$omschrijving','$target')"; $results = mysql_query($query, $dbi);
mysql_close($dbi); ?>
|