Jump to content

[SOLVED] Problems uploading pictures to database


affordit

Recommended Posts

Trying to use the script below to upload pictures to mysql DB. The variable is not getting passed to the next page. Can anyone help, what am I missing?

 

This is the form:

<form action=submit_pic.php method='POST' enctype='multipart/form-data'>
<table>

<tr>
<td>Choose a file</td><td align='left'><INPUT TYPE='file' NAME='img1' SIZE='30'></td>
</tr>
<tr>
<td colspan='2' align='center'><input type=submit name='Submit' value='ADD'></td>
</tr>
</table>
</form>

 

This is the next page:

<?php
include("teao_1_dbinfo2.inc");
if ($img1_name != "") {
        
$img2_name = ("$img1_name");

        @copy("$img1" , "$main_dir/$img2_name") 
               
                or die("Couldn't Upload Your File.");


} else {

echo "";
}
if ($img2_name == "") 
{$img2_name = 'no.jpg';}
if ($img2_name != "")
{$pic1 = "<img src=uploads/$img2_name width=320 height=200>";}
if ($link == "") 
{$link = '';}
{$pic = "$pic1";}
if ($link != "")
{$pic = "<a href=http://$link target=_blank>$pic1</a>";}
if ($img2_name == "")
{$pic1 = '';}
?>
<?php

include("conn.inc");
mysql_query ("INSERT INTO pics (id, picture) 
                VALUES ('', '$pic')
             ");

print ("<p>");
print ($pic);


if ($img1_name != "") {
echo "<H1>File Upload Successful!</H1><br><P>Successfully Sent: $img2_name, a $img2_size byte file with the extension type of $img2_type </P>";
} else {

echo "";
}
?>
</body>
</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.