Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Uploading a file --> FTP
Old 06-01-2009, 08:51 AM Uploading a file --> FTP
Junior Talker

Posts: 1
Name: Pieter
Trades: 0
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);
?>
excellion is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to Uploading a file --> FTP
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.08281 seconds with 12 queries