Hi,
What I am trying to do with no success is from a form in php, take get people to select an image from there computer and upload it to the mysql database, but only taking the name of the file and storing the image in a folder....
but every code i try doesnt work....
i tried this
<Font Face="arial" size="2">
<?php
if ($post == "yes") {
$dbuser = "*";
$dbserver = "localhost";
$dbpass = "";
$dbname = "cfteenz_profile3";
//THEN WE ARE ADDING A NEW RECORD SUBMITTED FROM THE FORM
//REPLACE THE FIELD CONTENTS SO THEY DON'T MESS UP YOUR QUERY
//CONNECTION STRING
mysql_connect($dbserver, $dbuser, $dbpass)
or die ("UNABLE TO CONNECT TO DATABASE");
mysql_select_db($dbname)
or die ("UNABLE TO SELECT DATABASE");
/-- SECTION: 9994SQL --/
$sql = "INSERT INTO profile (
Name,
Email,
Are_you_a_model_actress_etc,
Biography,
Filmography,
Links,
Contact,
picture_name
$addl_insert_crit ) VALUES ( '$Name',
'$Email',
'$Are_you_a_model_actress_etc',
'$Biography',
'$Filmography',
'$Links',
'$Contact',
'$picture_name'
$addl_insert_values )";
exec("cp $picture /usr/home/cfteenz/public_html/ifi/files/$picture_name");
echo "temp file: $picture<br>\n";
echo "file name: $picture_name<br>\n";
echo "<br>\n";
echo "<img src=files/$picture_name><br>\n";
if ($sql_debug_mode==1) { echo "<BR>SQL: $sql<BR>"; }
$result = mysql_query($sql);
if ($result == 1) {
echo "Record Inserted";
} else {
echo "Error inserting record (9994SQL)";
}
//** END INSERT SQL **
} //END IF POST = YES FOR ADDING NEW RECORDS
if (!$post) {
//THEN WE ARE ENTERING A NEW RECORD
//** BEGIN ADD NEW FORM**
/-- SECTION: 9994FORM --/
?>
<form method="post" action="<?php echo $thispage; ?>?proc=New&post=yes&<?php echo $pagevars; ?>">
<center>
<TABLE>
<TR>
<td>
<B>NAME:</B>
</td>
<td>
<input type="Name" name="Name" size="20">
</TR>
<TR>
<td>
<B>EMAIL:</B>
</td>
<td>
<input type="Email" name="Email" size="20">
</TR>
<TR>
<td>
<B>ARE_YOU_A_MODEL_ACTRESS_ETC:</B>
</td>
<td>
<input type="Are_you_a_model_actress_etc" name="Are_you_a_model_actress_etc" size="20">
</TR>
<TR>
<td>
<B>BIOGRAPHY:</B>
</td>
<td>
<textarea name="Biography" rows="4" cols="35"></textarea>
</TR>
<TR>
<td>
<B>FILMOGRAPHY:</B>
</td>
<td>
<textarea name="Filmography" rows="4" cols="35"></textarea>
</TR>
<TR>
<td>
<B>LINKS:</B>
</td>
<td>
<textarea name="Links" rows="4" cols="35"></textarea>
</TR>
<TR>
<td>
<B>CONTACT:</B>
</td>
<td>
<textarea name="Contact" rows="4" cols="35"></textarea>
</TR>
<TR>
<td>
<B>PICTURE:</B>
</td>
<td>
<input type="File" name="picture" size="25">
</TR>
<tr>
<td>
</td>
<td>
<input type="submit" value="Upload" name="submit">
<input type="reset" value="Reset" name="reset">
</td>
</tr>
</table>
</center>
<BR>
<?php
if ($submit) {
$db = mysql_connect("$localhost","$dbuser","$dbpass");
mysql_select_db("$dbname",$db);
$sql = "INSERT INTO profile (picture_name) ".
"VALUES ('$picture_name')";
exec("cp $picture /usr/home/cfteenz/public_html/ifi/files/$picture_name");
echo "temp file: $picture<br>\n";
echo "file name: $picture_name<br>\n";
echo "<br>\n";
echo "<img src=files/$picture_name><br>\n";
}
?>
</form>
<?php
} //END if post=""
//** END ADD NEW ENTRY FORM**
?>
</font>
it picks it up... but end with this info
temp file: C:\My Documents\My Pictures\001.jpg
file name:
No File Specified
which doesnt reference a image, wont upload any image so i tried a script like this ... again with no success...
<Font Face="arial" size="2">
<?php
if ($post == "yes") {
$dbuser = "**";
$dbserver = "localhost";
$dbpass = "**";
$dbname = "cfteenz_profile3";
//THEN WE ARE ADDING A NEW RECORD SUBMITTED FROM THE FORM
//REPLACE THE FIELD CONTENTS SO THEY DON'T MESS UP YOUR QUERY
//CONNECTION STRING
mysql_connect($dbserver, $dbuser, $dbpass)
or die ("UNABLE TO CONNECT TO DATABASE");
mysql_select_db($dbname)
or die ("UNABLE TO SELECT DATABASE");
/-- SECTION: 9994SQL --/
$sql = "INSERT INTO profile (
Name,
Email,
Are_you_a_model_actress_etc,
Biography,
Filmography,
Links,
Contact,
picture_name
$addl_insert_crit ) VALUES ( '$Name',
'$Email',
'$Are_you_a_model_actress_etc',
'$Biography',
'$Filmography',
'$Links',
'$Contact',
'$picture_name'
$addl_insert_values )";
if ($picture_name_type == 'image/gif') {
$type = '.gif';
}
if ($picture_name_type == 'image/pjpeg') {
$type = '.jpg';
}
if ($picture_name_type == 'image/x-png') {
$type = '.jpg';
}
$newfile = substr($picture_name, -7);
if($picture_name = '') {
print("No file was selected!");
}
elseif($picture_name_size > $MaxFileSize) {
print("The file to upload is too big");
}
else {
$global_db = mysql_connect('localhost','*', '**');
mysql_select_db('cfteenz_profile3', $global_db) or die("Connection error");
$query = "INSERT INTO profile (picture_name) VALUES ('$newfile$type')";
$result = mysql_query($query) or die("ERROR");
move_uploaded_file($picture_name, "/usr/home/cfteenz/public_html/ifi/files/$newfile$type");
echo "file name: $newfile$type<br>\n";
}
if ($sql_debug_mode==1) { echo "<BR>SQL: $sql<BR>"; }
$result = mysql_query($sql);
if ($result == 1) {
echo "Record Inserted";
} else {
echo "Error inserting record (9994SQL)";
}
//** END INSERT SQL **
} //END IF POST = YES FOR ADDING NEW RECORDS
if (!$post) {
//THEN WE ARE ENTERING A NEW RECORD
//** BEGIN ADD NEW FORM**
/-- SECTION: 9994FORM --/
?>
<form method="post" action="<?php echo $thispage; ?>?proc=New&post=yes&<?php echo $pagevars; ?>">
<center>
<TABLE>
<TR>
<td>
<B>NAME:</B>
</td>
<td>
<input type="Name" name="Name" size="20">
</TR>
<TR>
<td>
<B>EMAIL:</B>
</td>
<td>
<input type="Email" name="Email" size="20">
</TR>
<TR>
<td>
<B>ARE_YOU_A_MODEL_ACTRESS_ETC:</B>
</td>
<td>
<input type="Are_you_a_model_actress_etc" name="Are_you_a_model_actress_etc" size="20">
</TR>
<TR>
<td>
<B>BIOGRAPHY:</B>
</td>
<td>
<textarea name="Biography" rows="4" cols="35"></textarea>
</TR>
<TR>
<td>
<B>FILMOGRAPHY:</B>
</td>
<td>
<textarea name="Filmography" rows="4" cols="35"></textarea>
</TR>
<TR>
<td>
<B>LINKS:</B>
</td>
<td>
<textarea name="Links" rows="4" cols="35"></textarea>
</TR>
<TR>
<td>
<B>CONTACT:</B>
</td>
<td>
<textarea name="Contact" rows="4" cols="35"></textarea>
</TR>
<TR>
<td>
<B>PICTURE:</B>
</td>
<td>
<input type="File" name="picture_name" size="25">
<input type=hidden name=MaxFileSize value=64000>
</TR>
<tr>
<td>
</td>
<td>
<input type="submit" value="Upload" name="submit">
<input type="reset" value="Reset" name="reset">
</td>
</tr>
</table>
</center>
<BR>
<?php
if ($submit) {
$db = mysql_connect("$localhost","$dbuser","$dbpass");
mysql_select_db("$dbname",$db);
$sql = "INSERT INTO profile (picture_name) ".
"VALUES ('$picture_name')";
exec("cp $picture /usr/home/cfteenz/public_html/ifi/files/$picture_name");
echo "temp file: $picture<br>\n";
echo "file name: $picture_name<br>\n";
echo "<br>\n";
echo "<img src=files/$picture_name><br>\n";
}
?>
</form>
<?php
} //END if post=""
//** END ADD NEW ENTRY FORM**
?>
</font>
this resulted in no file selected, no image uploaded etc...
as you can tell im only learning php and prob scripted it wrong...
if you have any ideas on how to fix this please help....
what i want in the end is to view this on an automated page
[image] View Gallery Name (for each member) I have it working without the pic, but would love it working with the pic...
Cheers
DirtyRat...