Andrius Posted November 14, 2006 Share Posted November 14, 2006 [code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title></head><body><?phpif($_POST['upload']){# edit # $maxwidth = 250; $maxheight = 250; $max_filesize = 102400; $uploads = 'PI'; $types_array = array('image/gif','image/jpeg','image/x-png');# end edit #if($_FILES['image']['name'] == ""){ echo "Please select a file to upload!\n"; exit;}if(!in_array($_FILES['image']['type'], $types_array)){ echo "That file type is not allowed!\n"; exit;} $max_filesize_kb = ($max_filesize / 1024);if($_FILES['image']['size'] > $max_filesize){ echo "You file is too large, files may be up to ".$max_filesize_kb."kb\n"; exit;} $imagesize = getimagesize($_FILES['image']['tmp_name']); $imagewidth = $imagesize[0]; $imageheight = $imagesize[1];if($imagewidth > $maxwidth || $imageheight > $maxheight){ echo "Your images's dimensions are too large, images may be up to ".$maxwidth."px x ".$maxheight."px in size\n"; exit;}$pic=($_FILES['image']);// Connects to your Database mysql_connect("localhost", "12345, "12345") or die(mysql_error()); mysql_select_db("mycanadate") or die(mysql_error());//Writes the information to the database mysql_query("INSERT INTO `canadate_members` (profile_image) VALUES ('$pic')");if(move_uploaded_file($_FILES['image']['tmp_name'], $uploads.'/'.$_FILES['image']['name'])){echo "done";}else { echo "Couldn't upload ".$_FILES['image']['name']."\n";}}?> <form name="uploader" method="post" action="" enctype="multipart/form-data"> <input type="file" name="image" style="width:300px;cursor:pointer" /> <input type="submit" name="upload" value="Upload Image" /></form></body></html>[/code]Basically I'm trying to upload a file with some checks and then input the uploaded filename into my database under the profile_image field which resides in canadate_members table in the database canadate. Any and ALL help will be greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/27167-upload-file-code-not-working-properly/ Share on other sites More sharing options...
Andrius Posted November 14, 2006 Author Share Posted November 14, 2006 ^ bump Link to comment https://forums.phpfreaks.com/topic/27167-upload-file-code-not-working-properly/#findComment-124316 Share on other sites More sharing options...
The Little Guy Posted November 14, 2006 Share Posted November 14, 2006 Well... Why isn't it working? What is happening that is making it not work? Link to comment https://forums.phpfreaks.com/topic/27167-upload-file-code-not-working-properly/#findComment-124317 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.