tags:

views:

27

answers:

2

I have this form:

<form action="after.php" method="post" id="divulgacao">
    <div style="float: left;width: 195px; margin-right: 10px;">
        <p class="pdados">Your name</p>
        <input class="campodivulgue" name="titulo" type="text" />
    </div>
    <div style="float: left;width: 195px; margin-right: 10px;">
        <p class="pdados">E-mail</p>
        <input class="campodivulgue" name="email" type="text" />
    </div>
    <div style="float: left; width: 195px; ">
        <p class="pdados">Your picture</p>
        <input style="float:left; height: 22px;"  type="file" name="file" id="file" />
    </div>                  
    <p align="right" style="margin-top: 10px;"><input class="btn" type="submit" name="button" id="button" value="Send" /></p>                       
</form>

What should I do so when the user clicks on the send button, the chosen file in the file field is uploaded using FTP? What should be the content of the file after.php

Do I have to put another form for file upload?

+2  A: 

You need to declare the enctype attribute in the form.

<form action="after.php" method="post" id="divulgacao" enctype="multipart/form-data">
Stephen
+1  A: 

example contents for after.php taken right from PHP Manual

$uploads_dir = '/uploads';
foreach ($_FILES["file"]["error"] as $key => $error) {
    if ($error == UPLOAD_ERR_OK) {
        $tmp_name = $_FILES["file"]["tmp_name"][$key];
        $name = $_FILES["file"]["name"][$key];
        move_uploaded_file($tmp_name, "$uploads_dir/$name");
    }
}
seengee
But what about the FTP part?
Rafael Carvalho
there doesn't have to be an FTP part unless you specifically need there to be for some reason?
seengee