eXcellion Posted June 1, 2009 Share Posted June 1, 2009 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: <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 $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); ?> Link to comment https://forums.phpfreaks.com/topic/160470-uploading-a-file-ftp/ Share on other sites More sharing options...
grissom Posted June 1, 2009 Share Posted June 1, 2009 Try putting this line of code in your HTML <INPUT TYPE = "HIDDEN" NAME = "MAX_FILE_SIZE" VALUE = "500000"> ie maybe like this <tr><td><INPUT TYPE = "HIDDEN" NAME = "MAX_FILE_SIZE" VALUE = "500000">Afbeelding:</td><td><input name="image" type="file"></td></tr> Next thing !! : Check the value of the variable $target. Use an echo statement to print $target on the screen, it might not be what you want it to be. Link to comment https://forums.phpfreaks.com/topic/160470-uploading-a-file-ftp/#findComment-846890 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.