
dbillings
Members-
Posts
190 -
Joined
-
Last visited
Never
Everything posted by dbillings
-
Your post username and mysql username use the same variable $username and I don't see a form submiss ion to populate your post array.
-
It doesn't work for Windows Home Edition which I have. I did a web search and I would have to restart my PC in safe mode and logon as administrator to adjust individual file permissions. Gotta love Home Edition.
-
You could download PHPBB and read their source code and see how they do it
-
figured it out. I needed to create a name for my file (duh) in my imagejpeg($image, $path.$randomname); Thanks for all the help shocker.
-
I have XP and and it doesn't have a security tab when I click properties. It has general, sharing and customize. It appears hopeless.
-
I am making an effort here and I don't want you to think I'm not searching the web with every effort to figure this out for myself. I have apache by the way and I can't figure out where to give myself full control. I think my user name is Dennis based on the services.msc you gave me. From what I read it appears that I would enter the following bit of code in the httpd.cofig... <Directory "C:/wamp/www/thumb"> UserDir enabled Dennis </Directory> I'm not sure if that has to go anywhere in particular but I added it and my webserver wouldn't start after I did it. I'd really appreciate any additional help you could offer.
-
I recieve the following error: Warning: imagejpeg() [function.imagejpeg]: Unable to open 'C:/wamp/www/thumb/' for writing: Permission denied in C:\wamp\www\image upload\resizeimages.php on line 62 If someone could just point me in the right direction that would be great. <?php if(isset($_REQUEST['submit'])){ $thumbarray = array(); $imagearray = array(); $dir = $_REQUEST['directory']; if(is_dir($dir)) { if ($dh = opendir($dir)){ while (($file = readdir($dh)) !== false) { if(filetype($dir . $file) == "file") { if(exif_imagetype($dir . $file) != IMAGETYPE_JPEG) { echo $dir . $file . " Resize failed not a JPEG image. <br />"; }else{ $tmpname = $dir.$file; echo $tmpname." Type: JPEG <br />"; $filesize = filesize($tmpname); $orig_image = imagecreatefromjpeg($tmpname); list($width, $height) = getimagesize($tmpname); if($filesize > 157286) { // Resize image if it's over 150 kb's. $percent = 157286 / $filesize; $newwidth = $width * $percent; $newheight = $height * $percent; $new_image = imagecreatetruecolor($newwidth, $newheight); imagecopyresampled($new_image, $orig_image, 0, 0, 0, 0,$newwidth, $newheight, $width, $height); } // Generate thumbnail images. $thumbw = 50; $thumbh = $thumbw / $width * $height; $thumb = imagecreatetruecolor($thumbw, $thumbh); imagecopyresampled($thumb, $orig_image, 0, 0, 0, 0, $thumbw, $thumbh, $width, $height); chmod("C:/wamp/www/thumb", 0777); imagejpeg($thumb, "C:/wamp/www/thumb/"); chmod("C:/wamp/www/image", 0777); imagejpeg($new_image, "C:/wamp/www/image/"); } } } closedir($dh); } }else{ echo "The submited directory is invalid."; } } ?> <form method="post" action="<?php $_SERVER['PHP_SELF']; ?>"> Directory<input type="text" name="directory"><br /> <input type="submit" name="submit" value="Submit"> </form>
-
You could use javascript <script type="text/javascript"> var browser=navigator.appName; var b_version=navigator.appVersion; var version=parseFloat(b_version); document.write("Browser name: "+ browser); document.write("<br />"); document.write("Browser version: "+ version); </script>
-
Well that is helpful and does point me in the right direction. Thank you
-
No takers, is the question not clear or doesn't anyone have any answers for me aka bump.
-
I was trying to use mkdir() and it gave me a you don't have permission error. I also tried using chmod() and make access all 777's still no good. Is there a setting that would appear using phpinfo() that would indicate to me weather I have permission or not and what is it's name if so.
-
Passing variables from function-function in class
dbillings replied to ChadNomad's topic in PHP Coding Help
She's too quick for me. <?php class a { private $test; function a() { $this->test = "hello"; } function b() { echo $this->test; } } ?> -
Not so much a PHP issue but an Apache (assuming you're using Apache) issue.
-
Adding Image Resize To My Current Upload Script
dbillings replied to sintax63's topic in PHP Coding Help
Should be imagecreatefromjpeg() -
Adding Image Resize To My Current Upload Script
dbillings replied to sintax63's topic in PHP Coding Help
pish posh Vbulletin has no problems with storing images in mysql. I have heard the same thing, but have never really investigated why. (I'm a good listner if some one would care to share.) You could use the same code to resize for directory storage the variables binarythumb and binaryimage can be stored anywhere your little heart desires. The addslashes is for database storage so the variables thumb and image would probably give you invalid images. -
Adding Image Resize To My Current Upload Script
dbillings replied to sintax63's topic in PHP Coding Help
By the way the script is a little broken for the fact I don't have instructions for the code if the jpg is actually smaller than 150 kb's. I wrote it to serve my purposes of shrinking monsterous 8.1 megapixel digital photo's for bandwidth friendly web use. -
Adding Image Resize To My Current Upload Script
dbillings replied to sintax63's topic in PHP Coding Help
Here's a script that stores images in mysql doing something similar to what your looking for. You'll need a table with the following fields... CREATE TABLE `images` ( `id` int(11) NOT NULL auto_increment, `name` varchar(32) NOT NULL, `description` varchar(300) NOT NULL, `size` int(6) NOT NULL, `date` timestamp NOT NULL default CURRENT_TIMESTAMP, `image` mediumblob NOT NULL, `thumb` mediumblob NOT NULL, PRIMARY KEY (`id`), KEY `date` (`date`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ; This code will resize the image (currently keeping it under 150 kb's) and create a thumbnail image. It doesn't have many frills and you will still be chewing up bandwidth unless you shrink the files on a localhost server on your own machine. It's currently setup strictly for jpegs. <?php if(isset($_REQUEST['upload'])) { ini_set('memory_limit', '200m'); $filesize = $_FILES['userfile']['size']; $filename = $_FILES['userfile']['name']; $filetype = $_FILES['userfile']['type']; $tmpname = $_FILES['userfile']['tmp_name']; $desc = $_REQUEST['description']; $desc = htmlspecialchars($desc); if($filetype == 'image/pjpeg') { $orig_image = imagecreatefromjpeg($tmpname); list($width, $height) = getimagesize($tmpname); if($filesize > 157286) { // Resize image if it's over 150 kb's. //When I wrote this I was mainly concerned with keeping the image file equal //to 150 kb's it could easily be converted to adjust to certain dimensions. $percent = 157286 / $filesize; $newwidth = $width * $percent; $newheight = $height * $percent; $new_image = imagecreatetruecolor($newwidth, $newheight); imagecopyresampled($new_image, $orig_image, 0, 0, 0, 0,$newwidth, $newheight, $width, $height); } // Generate thumbnail images. $thumbw = 50; $thumbh = $thumbw / $width * $height; $thumb = imagecreatetruecolor($thumbw, $thumbh); imagecopyresampled($thumb, $orig_image, 0, 0, 0, 0, $thumbw, $thumbh, $width, $height); ob_start(); // Start capturing stdout. imagejpeg($thumb); // As though output to browser. $binarythumb = ob_get_clean(); // the raw jpeg image data. ob_start(); imagejpeg($new_image); $binaryimage = ob_get_clean(); $thumb = addslashes($binarythumb); $image = addslashes($binaryimage); $filesize = $filesize * $percent; // create mysql query. include("mysql_connect.php"); $query = "INSERT INTO images (name, description, size, image, thumb) VALUES ('$filename','$desc','$filesize','$image','$thumb')"; $result = mysql_query($query) or die(mysql_error()); if($result) { echo " <pre> Filename: $filename Filesize: ".$filesize * $percent." Filetype: $filetype Filestatus: Your file uploaded successfully! </pre>"; }else{ echo "File failed to upload."; } }else{ echo "This program only supports the upload of jpeg files <br /> your image is a $filetype file."; } } ?> <html> <head> </head> <body> <fieldset><legend>Upload Images</legend> <form method="post" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="2000000"> <label id='label'>Select image:</label><input id='input' name="userfile[]" type="file" id="userfile"><br /> <label id='label'>Description:</label><br /> <textarea name='description' cols='30' rows='7'></textarea><br /> <input id='submit' name="upload" type="submit" class="box" id="upload" value=" Upload "></td> </tr> </table> </form> </fieldset> </body> </html> -
simple imagecopymerge code (just don't know what's wrong)
dbillings replied to yekis's topic in PHP Coding Help
are your images stored in the same directory as the file? If not you'll need to include the correct path. <?php $background = imagecreatefrompng("images/background.png"); ?> -
Quick and simple way to display images from a database?
dbillings replied to Moron's topic in PHP Coding Help
By the way the id=1 will require that you have an id stored in your database that actually equals one. You will probably want to replace that with a php variable to give you more flexibility. -
Quick and simple way to display images from a database?
dbillings replied to Moron's topic in PHP Coding Help
You're best bet is to do the following I had issues with images at first too. I don't know how many images you're trying to display at once but here's an example assuming you only want one image at a time. First the previous code posted by corbin is stored in a file called view.php (or any other name you would like to call it but lets assume it's called view.php). Then you create a seperate page that has the following img tag in it. <img src='view.php?id=1 title='some title' alt='some alt'><img /> And voila, should work. -
[SOLVED] Create thumbnail/ store in MySQL problem
dbillings replied to dbillings's topic in PHP Coding Help
Solution <?php if(isset($_REQUEST['upload'])) { ini_set('memory_limit', '200m'); $filesize = $_FILES['userfile']['size']; $filename = $_FILES['userfile']['name']; $filetype = $_FILES['userfile']['type']; $tmpname = $_FILES['userfile']['tmp_name']; $desc = $_REQUEST['description']; if($filetype == 'image/pjpeg') { $orig_image = imagecreatefromjpeg($tmpname); list($width, $height) = getimagesize($tmpname); if($filesize > 157286) { // Resize image if it's over 150 kb's. $percent = 157286 / $filesize; $newwidth = $width * $percent; $newheight = $height * $percent; $new_image = imagecreatetruecolor($newwidth, $newheight); imagecopyresized($new_image, $orig_image, 0, 0, 0, 0,$newwidth, $newheight, $width, $height); } // Generate thumbnail images. $thumbw = 50; $thumbh = $thumbw / $width * $height; $thumb = imagecreatetruecolor($thumbw, $thumbh); imagecopyresized($thumb, $orig_image, 0, 0, 0, 0, $thumbw, $thumbh, $width, $height); ob_start(); // Start capturing stdout. imagejpeg($thumb); // As though output to browser. $binarythumb = ob_get_contents(); // the raw jpeg image data. $thumb = addslashes($binarythumb); imagejpeg($new_image); $binaryimage = ob_get_clean(); $image = addslashes($binaryimage); // create mysql query. include("mysql_connect.php"); $query = "INSERT INTO trinity_images (name, description, size, image, thumb) VALUES ('$filename','$desc','$filesize','$image','$thumb')"; // var_dump($query); $result = mysql_query($query) or die(mysql_error()); if($result) { echo " <pre> Filename: $filename Filesize: ".$filesize * $percent." Filetype: $filetype Filestatus: Your file uploaded successfully! </pre>"; }else{ echo "File failed to upload."; } }else{ echo "This program only supports the upload of jpeg files <br /> your image is a $filetype file."; } } ?> <html> <head> </head> <body> <?php echo $newfilename; ?> <fieldset><legend>Upload Images</legend> <form method="post" enctype="multipart/form-data"> <input type="hidden" action="<?php $_SERVER['PHP_SELF']; ?>" name="MAX_FILE_SIZE" value="2000000"> <label id='label'>Select image:</label><input id='input' name="userfile" type="file" id="userfile"><br /> <label id='label'>Description:</label><br /> <textarea name='description' cols='30' rows='7'></textarea><br /> <input id='submit' name="upload" type="submit" class="box" id="upload" value=" Upload "></td> </tr> </table> </form> </fieldset> </body> </html> -
[SOLVED] Create thumbnail/ store in MySQL problem
dbillings replied to dbillings's topic in PHP Coding Help
Ok I'm running into problems again, I reworked my code and my problem is that when I use imagecopyresized($thumb, $orig_image, 0, 0, 0, 0, $thumbw, $thumbh, $width, $height); I try to upload $thumb to mysql and it is storing Resource id # 5 rather than the resource itself. How do I solve this? Here's my new code: <?php if(isset($_REQUEST['upload'])) { ini_set('memory_limit', '200m'); $filesize = $_FILES['userfile']['size']; $filename = $_FILES['userfile']['name']; $filetype = $_FILES['userfile']['type']; $tmpname = $_FILES['userfile']['tmp_name']; $desc = $_REQUEST['description']; if($filetype == 'image/pjpeg') { $orig_image = imagecreatefromjpeg($tmpname); list($width, $height) = getimagesize($tmpname); if($filesize > 157286) { // Resize image if it's over 150 kb's. $percent = 157286 / $filesize; $newwidth = $width * $percent; $newheight = $height * $percent; $new_image = imagecreatetruecolor($newwidth, $newheight); imagecopyresized($new_image, $orig_image, 0, 0, 0, 0,$newwidth, $newheight, $width, $height); } // Generate thumbnail images. $thumbw = 50; $thumbh = $thumbw / $width * $height; $thumb = imagecreatetruecolor($thumbw, $thumbh); imagecopyresized($thumb, $orig_image, 0, 0, 0, 0, $thumbw, $thumbh, $width, $height); // create mysql query. include("mysql_connect.php"); $query = "INSERT INTO trinity_images (name, description, size, image, thumb) VALUES ('$filename','$desc','$filesize','$image','$thumb_image')"; $result = mysql_query($query) or die(mysql_error()); if($result) { echo " <pre> Filename: $filename Filesize: ".$filesize * $percent." Filetype: $filetype Filestatus: Your file uploaded successfully! </pre>"; }else{ echo "File failed to upload."; } }else{ echo "This program only supports the upload of jpeg files <br /> your image is a $filetype file."; } } ?> <html> <head> </head> <body> <?php echo $newfilename; ?> <fieldset><legend>Upload Images</legend> <form method="post" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="2000000"> <label id='label'>Select image:</label><input id='input' name="userfile" type="file" id="userfile"><br /> <label id='label'>Description:</label><br /> <textarea name='description' cols='30' rows='7'></textarea><br /> <input id='submit' name="upload" type="submit" class="box" id="upload" value=" Upload "></td> </tr> </table> </form> </fieldset> </body> </html> -
[SOLVED] Create thumbnail/ store in MySQL problem
dbillings replied to dbillings's topic in PHP Coding Help
figured it out. -
I'm trying to store an image file in mysql after I resize the image to a value equal or below .300 mb. The data always ends up being 14 bytes I'm not sure whats going wrong here. <?php ###################################### ### Script - uploadimages.php ### Author - Billings ### Created - 12/14/2007 ###################################### if(isset($_REQUEST['delete'])){ $id= $_REQUEST['id']; include("mysql_connect.php"); $query= "DELETE FROM trinity_images WHERE id='$id'"; $result= mysql_query($query)or die(); if($result){ echo "Image deleted."; } } if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0) { ini_set('memory_limit', '200m'); $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; if($fileSize > 314573) { // Resize image if it's over .300 mb's. if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } $percent = 314573 / $fileSize; echo "Percent: ".$percent; echo "<br />Filesize: ".$fileSize; $newfilesize = $fileSize * $percent; echo "<br />New filesize: ".$newfilesize; list($width, $height) = getimagesize($tmpName); echo "<br />Width: ".$width; echo "<br />Height: ".$height; $newwidth = floor($width * $percent); $newheight = floor($height * $percent); echo "<br />New width: ".$newwidth; echo "<br />New height: ".$newheight; $newimage = imagecreatetruecolor($newwidth, $newheight); $source = imagecreatefromjpeg($tmpName); imagecopyresized($newimage, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); } if($filetype == "image/pjpeg" || "image/gif" || "image/png"){ include("mysql_connect.php"); $query = "INSERT INTO trinity_images (name, type, size, data ) ". "VALUES ('$fileName' , '$fileType' , '$newfilesize', '$newimage')"; $data = mysql_query($query) or die('Error: '.mysql_error()); mysql_close(); if($data) { echo "<br />File $fileName uploaded<br />"; }else{ echo "<br />File $fileName failed to upload<br />"; } }else{ echo "<br />File type ".$filetype." not allowed. Must be JPEG,GIF or PNG.<br />"; } } ?> <fieldset><legend>Upload Images</legend> <form method="post" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="2000000"> <label id='label'>Select image:</label><input id='input' name="userfile" type="file" id="userfile"><br /> <input id='submit' name="upload" type="submit" class="box" id="upload" value=" Upload "></td> </tr> </table> </form> </fieldset>
-
Try WAMP. google it.