I don't know how many of you are familiar with Vb (www.vbulletin.com) but I
am using the message board software and adding all that I can to it! :)

I am wanting my users to be able to add a photo to their profiles. So I am
trying to intergrate a upload script, that will upload the address to the
image (stored on the site) into the correct ID number of the user.

I have made it where it will upload the file to the correct folder and will
put a link in the database, but I cannot figure it all out. Listed below is
what I have in a .php file, but if you are familiar with the templates and
everything with vb, then I will post the code I have that is not working.

This code below works great.. but has not ability to add the image path or
anything to the correct user with ID.

------- code snippet = test.php ---
<form enctype="multipart/form-data" method="post"  action="<?php echo
$PHP_SELF ?>">
Upload a Photo<br>
<input type="File" name="picture" size="25">
<br><br>
<input type="submit" name="submit" value="Upload">
</form>

<?php
// Information needed to connect to the database
define("SQL_SERVER", "localhost");
define("SQL_UID", "USERNAME");
define("SQL_PWD", "PASSWORD");
define("SQL_DB", "DATABASE NAME");

// After the file has been chosen and they click submit this will happen
if ($submit) {

    $connection = mysql_pconnect(SQL_SERVER, SQL_UID, SQL_PWD);

    mysql_select_db(SQL_DB, $connection);

    $sql = "INSERT INTO user (picture_name) ".
        "VALUES ('$picture_name')";
    mysql_query($sql);

    exec("cp $picture /root/to/the/images/$picture_name");

    // Echo's out the file that was upload to show that it succeeded.
    echo "temp file: $picture<br>\n";
    echo "file name: $picture_name<br>\n";
    echo "file size: $picture_size<br>\n";
    echo "file type: $picture_type<br>\n";
    echo "<br>\n";
    echo "<img src=images/$picture_name><br>\n";

    return 0;
}

?>
------- code snippet = test.php ---

Here is what I altered the form code to look like for the modify and
registration templates.

--- code ---
<tr bgcolor="{firstaltcolor}">
<td valign=top><normalfont><b>Upload Picture :</b><br>
<smallfont>Please select a photo from your hard drive to post on the
site.</smallfont></normalfont></td>
<td valign=top><input type="File" class="bginput" name="picture_name"
size="25"</td></tr>
--- end code ---

I think for this to work properly it will have to not be called
"picture_name" but something along the lines of "$bbuserinfo[picture_name]"
to work... not for sure yet.


After that here is some of the code I have that replaces the submission part
of the above code. Since I added the form and everything to an already
existing if action statement I just added the below code to that but.. it
does not seem to work.

--- code ---
  // Photo Upload
  if ($picture_name !="") {
    $picture_name=$picture_name;
    exec("cp $picture /root/to/the/images/$picture_name");
  } else {
    $picture_name="";
  }
  // End Photo Upload
--- end code ---

and for it to go along with the $bbuserinfo[picture_name] idea here is what
the code should look like :

--- code ----
  // Photo Upload
  if ($bbuserinfo[picture_name] !="") {
    $bbuserinfo[picture_name]=$bbuserinfo[picture_name];
    exec("cp $picture /root/to/the/images/$picture_name");
  } else {
    $bbuserinfo[picture_name]="";
  }
  // End Photo Upload
--- end code ---

The if action already looks for an ID.. if 0 it fails, else it continues...
so can anyone help me figure this one out... or tell me what a good command
is for selecting the ID out of the database for the user that is logged in..

thanks
BradC


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to