Jump to content

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>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.