# Php-upload-programm

**URL:** <https://forum.kirupa.com/t/php-upload-programm/191357>\
**Category:** Uncategorized\
**Created:** [June 19, 2006, 11:00pm UTC](https://forum.kirupa.com/t/php-upload-programm/191357 "2006-06-19T23:00:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Exos\_Sho](https://avatars.discourse-cdn.com/v4/letter/e/ed655f/32.png) [@Exos\_Sho](https://forum.kirupa.com/u/Exos_Sho)\
**Post date:** [June 19, 2006, 11:00pm UTC](https://forum.kirupa.com/t/php-upload-programm/191357/1 "2006-06-19T23:00:08Z")

</div>

yesterday i started writing a little program, which uploads files (till now pics prefered) to the folder, which contains the PHP-file.  
on the first page, u select the file u want to upload, and may enter a Title( in order to enable a gallery-database with my-sql);  
second page shows u wether the data has been sent to the database([COLOR=Red]THIS IS THE MAIN PROBLEM because it wont save anything to the database[/COLOR]), info about the file, where its gonna be saved, or if a file(pic) alrady exists with the same name, in this case the script should view the “new-version”(which cant be uploaded) and the “old-version”(which alrady exists"[COLOR=Red]but problem is, it wont show the already existing file  
[COLOR=Black]here are the two scripts, and css(in order u need to see more)  
**FIRST FILE,**  
[/COLOR][/COLOR]

```html

<html>
<head>
<link rel="stylesheet" type="text/css" href="style_1.css">
</head>
<body>
<div style="background-color:#efefef;width:480px;border:5px solid #00c000;padding:1px;margin:0px auto;text-align:center;">
<form enctype="multipart/form-data" action="showit.php" method="post">
data: <input name="upfile" type="file" size="25">
<p>titel: <input name="titel" size="25">
<p><input type="submit" value="send" name="sent">
</form>
</div>
</body>
</html>

```

\*\*SECOND FILE  
\*\*

```php

<html>
<head>
<link rel="stylesheet" type="text/css" href="style_1.css">
</head>
<body>
<div style="background-color:#efefef;width:480px;margin:0px auto;border:5px solid #00c000;padding:1px;text-align:center;">
<?php
if(isset($sent))
{
    mysql_connect(localhost,root);
    mysql_select_db("daten");
    $sqlab = "insert upload (name, typ, titel) values ($upfile_name, $upfile_type, $titel)";
    mysql_query($sqlab);
 $num = mysql_affected_rows();
   }
 if ($num>0)
      {
         echo "<g>one data has been added<p></g>";
      }
      else if($num<=0)
      {
         echo "<r>an Error appeared, ";
         echo "no data has been added<p></r>";
}
    echo "<h3><ul><k>control:</k></ul></h3><p>";
    echo "original-name: <zitat>$upfile_name</zitat><br>";
    echo "size: <zitat>$upfile_size Byte</zitat><br>";
    echo "type: <zitat>$upfile_type</zitat><br>";

    $dname = explode(".",$upfile_name);
    $dnamesize = count($dname);
    $upfile_ext = $dname[$dnamesize-1];
    echo "data-extension: <zitat>" . $upfile_ext . "</zitat><br>";
    list($headw, $headh) = getimagesize($upfile);
    echo "original-properties: <zitat>" . $headw . "x" . $headh . "</zitat><br>";
    $verz = getcwd();
     $exi = $verz ."/". $upfile_name;
    if($upfile_size>0 && !file_exists($exi))
    {
    echo "new home of " . $upfile_name . " : <zitat>" . $verz. "</zitat><br>";
        copy($upfile,$upfile_name);
        echo "data has been copied in: <zitat>$upfile_name</zitat><br>";
        if($headw>470)
        {
        echo "<img src= $upfile_name width= '470'>"; 
        } 
        else
        {
        echo "<img src= $upfile_name>"; 
        }
    }
    else if(file_exists($exi))
    {
        echo "<r>a file with the name: <zitat>" . $upfile_name . "</zitat> does already exist!</r><br>";
        echo "<table>";
        echo "<tr><td><k>new-" . $upfile_name . "</k></td><td><k>old-" . $upfile_name . "</k></td></tr>";
        echo "<tr><td><img src= $upfile_name width= '200'></td><td><img src= $exi width= '200></td></tr>";
        echo "</table>";
    }
    else
    {
        echo "copy-error: data does not exist";
        echo " or false data-type";
    }
?>
</div>
</body>
</html>

```

and the CSS, which isnt really necessary

> 

/_----standarts-_/  
div {background-color:#efefef;width:480px;margin:0px auto;border:5px solid #00c000;padding:1px;text-align:center;}  
body{font-family:Verdana; font-size:10pt; color:#636363; background-color:#c3c3c3}

- {font-size:10pt;color:#636363;}  
/_-_/  
/_link_/  
a:link {color:636363}  
a:visited {color:606060}  
a:hover {color:606060; background-color:#a3a3a3}  
/_-_/  
/_tabel_/  
table {border:solid 3px #ffffff;background-color:#efefef;margin:auto}  
td {font-family:Verdana; font-size:10pt; color:#636363; background-color:#c3c3c3}  
/_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__/

/_----class-selector-_/  
.top {background-color:#CCCCCC; color:#333333}  
.ul {text-decoration:underline}  
.ol {text-decoration:line-through}  
.fett {font-weight:bold}  
.italic {font-style:italic}  
/_-_/  
/_color_/  
.red {color:#FF0000}  
.blue {color:#0000FF}  
.green {color:#00FF00}  
.yellow {color:#FFFF00}  
.key {color:#000000}  
.white {color:#FFFFFF}  
/_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\__/

/_----typ-selector-_/  
/_text-typen_/  
zitat {text-shadow:#333333; color:#0066FF}  
/_font-color_/  
r {color:#FF0000}/_red_/  
b {color:#0000FF}/_blue_/  
g {color:#00FF00}/_green_/  
y {color:#FFFF00}/_yellow_/  
k {color:#000000}/_key_/  
w {color:#FFFFFF}/_white_/  
/_-_/  
/_background-color_/  
runder {background-color:#FF0000}/_red_/  
bunder {background-color:#0000FF}/_blue_/  
gunder {background-color:#00FF00}/_green_/  
yunder {background-color:#FFFF00}/_yellow_/  
kunder {background-color:#000000}/_key_/  
wunder {background-color:#FFFFFF}/_white_/  
/_-_/  
/_font-decoration_/  
top {background-color:#CCCCCC; color:#333333}  
ul {text-decoration:underline}  
ol {text-decoration:line-through}  
fett {font-weight:bold}  
italic {font-style:italic}  
/_-_/

[COLOR=Red]  
[COLOR=Black]maybe i have to say that i am a very noob in php, and php/mysql, so please be patient:ub:  
thank u  
[/COLOR] [/COLOR]
