ClioSport.net

Register a free account today to become a member!
Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

  • When you purchase through links on our site, we may earn an affiliate commission. Read more here.

FAO Web design people.



  RRS, 172, ST3, VTS
Need a MYSQL script which will let web user go to a page, and upload image + text to mysql database, then display uploaded image + text on an HTML page.
 
  RRS, 172, ST3, VTS
yeah i cant find anything as basic as i want, i dont nee the user to login or setup user rights etc. Just a script to allow image + text upload, then a script to display the image and text in a table.
 
Modify this as you need to, it's probably horrific code, but it works. Obviously needs security addressing if it's going to be published.

PHP:
<?php session_start(); ?>
<html>
<form action="upload.php" method ="post">
<table>
<tr><td><input type = "hidden" name="MAX_FILE_SIZE" value = "102400" /></td></tr>
<tr><td>Filename:</td><td><input type = "text" name="filename" value = "" /></td></tr>
<tr><td>Select File: </td><td><input type = "file" name = "fupload" /></td></tr>
<tr><td>Text:</td><td><input type = "text" name="txt" value = "" /></td></tr>
<tr><td><input type = "submit" value = "Upload!"></td></tr>
</table>
<?php
if (isset ($_FILES['fupload'])){
 
$filename = $_FILES['fupload']['name'];
$newfilename = $_POST[filename];
$newfilename = strtolower($newfilename);
$txt= $_POST[txt];
 
//printing file information
print "<table>";
print  "<tr><td>Original Name:</td><td> ". $_FILES['fupload']['name']."</td></tr>";
print    "<tr><td>New Name:</td><td> ".$newfilename."</td></tr>";
print  "<tr><td>Size: </td><td>". $_FILES['fupload']['size']."</td></tr>";
print  "<tr><td>Type: </td><td>". $_FILES['fupload']['type']. "</td></tr>";
print  "<tr><td>Error: </td><td>". $_FILES['fupload']['error']. "</td></tr>";
print "</table>";
 
 
//checking the type of file, if it is image it will display it
if ($_FILES['fupload']['type'] == "image/jpeg"){
    $source = $_FILES['fupload']['tmp_name'];
    $target = "products/images/".$newfilename. ".jpg";
    move_uploaded_file($source, $target); // or die ("Couldnt copy");
 
 
    //displaying the image
    $imagesize = getImageSize($target);
    $imgstr = "<p><img width=\"$size[0]\" height=\"$size[1]\" ";
    $imgstr .= "src=\"$target\" alt=\"uploaded image\" ></p>";
 
    $imagepath = $yoursite.$target;
 
    print $imgstr;
    print "The link to your image is: ".$yoursite.$target;//link to the image
    print $texthere;
 
 
}
}
//-------------------------------------------------------------------------------------
?>
</html>
 


Top