http://www.php-mysql-tutorial.com/php-mysql-upload.php
try this tutorial instead. The tutorial should have explained about how to get the file size, type etc from the $_FILES array. This tutorial does that very well and the code works for both images and files. HTH, David. --- In [email protected], Tanya Holliday <[EMAIL PROTECTED]> wrote: > > > Robert <[EMAIL PROTECTED]> wrote: > This some code I found in a very helpful article at > > > http://www.phpbuilder.com/columns/william19990908.php3?aid=41 > > printable version of the same article at: > > > http://www.phpbuilder.com/columns/william19990908.php3?print_mode=1 > > > here is the code from the article > > creating the table > > -> year INT(4), > -> make CHAR(20), > -> model CHAR(20), > -> price CHAR(15), > -> picture_name CHAR(25) > -> ); > > Creating a form to input the data from the net > > form enctype="multipart/form-data" method="post" action="<?php echo > $PHP_SELF ?>"> > year<br> > <input type="Text" name="year" size="25"> > <br> > make<br> > <input type="Text" name="make" size="25"> > <br> > model<br> > <input type="Text" name="model" size="25"> > <br> > price<br> > <input type="Text" name="price" size="25"> > <br> > picture<br> > <input type="File" name="picture" size="25"> > <br><br> > <input type="submit" name="submit" value="Upload"> > </form> > > > the form action > > action="<?php echo $PHP_SELF ?>" > > > The php code: > > <?php > > if ($submit) { > > $db = mysql_connect("$localhost","$joesauto","$password"); > > mysql_select_db("$joesauto",$db); > > $sql = "INSERT INTO joesauto > (year,make,model,price,picture_name) ". > "VALUES ('$year,$make,$model,$price,$picture_name')"; > > exec("cp $picture /full/path/to/joesauto/images/$picture_name"); > > echo "year: $year<br>\n"; > echo "make: $make<br>\n"; > echo "model: $model<br>\n"; > echo "price: $price<br>\n"; > echo "temp file: $picture<br>\n"; > echo "file name: $picture_name<br>\n"; > echo "file size: $picture_size<br>\n"; > echo "file type: $picture_type<br>\n"; > echo "<br>\n"; > echo "<img src=images/$picture_name><br>\n"; > > } > > ?> > I understand everything up until the php code's last five to six > lines. How did the author get "$picture_name" AND especially how id > he get the variables"$picture_size" and "$picture_type". > > On the form that field element is named picture so the php varialble > should be named $picture, which I an see. But it seems he made of or > got from somewhere three extra varialbles with data somewhere. As I > said ESPECIALLY $picture_size and $picture_type confuses me. > > Thanks > > I'm thinking its a type/mistake with the insert, and it should just be $picture in the values to insert. picture_name looks like the name of the field in the database. > > I don't know where $picture_type and $picture_size come into this code. Its no where else in the code. > > It seems like this code is leaving out a lot that you need to understand if your going to upload images. I seriously doubt those last two lines would have values echoing out. > > Tanya Holliday > > > > > > > > > The php_mysql group is dedicated to learn more about the PHP/MySQL web database possibilities through group learning. > > > > > --------------------------------- > YAHOO! GROUPS LINKS > > > Visit your group "php_mysql" on the web. > > To unsubscribe from this group, send an email to: > [EMAIL PROTECTED] > > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. > > > --------------------------------- > > > > > > [Non-text portions of this message have been removed] The php_mysql group is dedicated to learn more about the PHP/MySQL web database possibilities through group learning. Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/php_mysql/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
