Jump to content

dennismonsewicz

Members
  • Posts

    1,136
  • Joined

  • Last visited

Everything posted by dennismonsewicz

  1. Well to have PHP code read and execute ASP code
  2. It is a little difficult to explain, but I pretty much just had to rearrange some of my code and had to add this bit of code: $thumb_name = str_replace("jpg", ".jpg", $info['filename'] . $info['extension']); include "includes/sql.php"; $thumbq = "insert into thumbs (thumb_id, thumb_name) values (NULL, '$thumb_name')"; $thumquery = mysql_query($thumbq) or die("ERROR: " . mysql_error()); the $info var is used from an array reading the files out of the directory the thumbnails are in
  3. this is what it looks like in FF: In IE: And here is my code : //And we display the results $i = 0; // initialise counter while($result = mysql_fetch_array( $data )) { $kbsize = $result['size'] / 1024; //$name = str_replace($find, "<span class='yellowbg'>$find</span>", $result['name']); $size = str_replace($find, "<span class='yellowbg'>$find</span>", $kbsize); $type = str_replace($find, "<span class='yellowbg'>$find</span>", $result['type']); $categories = str_replace($find, "<span class='yellowbg'>$find</span>", $result['categories']); $id = $result['id']; $filecount = count($result['name']); $typenoimage = str_replace("image/", "", $type); echo '<img src="imageuploads/thumbs/' . $result['name'] . '" alt=' . $result['name'] . ' border=0>'; if($i == 5) { echo "<br />"; $i = 0; // reset counter } else { $i++; // increment counter } // check if $i is equal to 5, if it is echo line break and reset counter } echo '</td> </tr> </table>';
  4. ok it only does it for the first row in Firefox but in IE it counts up to 6 then for the rest of the row they are all in one row
  5. I need a way of checking to see if something equals a particular number, in my case 5, and every 5th entry create a new line. Any way to do this? echo '<table align=center border=0 width=650 cellpadding=4 cellspacing=0 class=imgtable> <tr> <td><u><b>Image</b></u></td> </tr> <tr> <td valign="top">'; //And we display the results while($result = mysql_fetch_array( $data )) { $kbsize = $result['size'] / 1024; //$name = str_replace($find, "<span class='yellowbg'>$find</span>", $result['name']); $size = str_replace($find, "<span class='yellowbg'>$find</span>", $kbsize); $type = str_replace($find, "<span class='yellowbg'>$find</span>", $result['type']); $categories = str_replace($find, "<span class='yellowbg'>$find</span>", $result['categories']); $id = $result['id']; $filecount = count($result['name']); $typenoimage = str_replace("image/", "", $type); if(count($result['name'] == 5)) { $br = "<br />"; } else { $br = ""; } echo '<img src="imageuploads/thumbs/' . $result['name'] . '" alt=' . $result['name'] . ' border=0>'; echo $br; }
  6. Anyone know how to get ASP pages to talk to PHP pages? Any good tutorials?
  7. <?php function createThumbs( $pathToImages, $pathToThumbs, $thumbWidth ) { // open the directory $dir = opendir( $pathToImages ); // loop through it, looking for any/all JPG files: while (false !== ($filename = readdir( $dir ))) { // parse path for the extension $info = pathinfo($pathToImages . $filename); // continue only if this is a JPEG image if ( strtolower($info['extension']) == 'jpg' ) { //echo "Creating thumbnail for {$filename} <br />"; // load image and get image size $img = imagecreatefromjpeg( "{$pathToImages}{$filename}" ); $width = imagesx( $img ); $height = imagesy( $img ); // calculate thumbnail size $new_width = $thumbWidth; $new_height = floor( $height * ( $thumbWidth / $width ) ); // create a new temporary image $tmp_img = imagecreatetruecolor( $new_width, $new_height ); // copy and resize old image into new image imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height ); // save thumbnail into a file imagejpeg( $tmp_img, "{$pathToThumbs}{$filename}" ); } } // close the directory closedir( $dir ); } // call createThumb function and pass to it as parameters the path // to the directory that contains images, the path to the directory // in which thumbnails will be placed and the thumbnail's width. // We are assuming that the path will be a relative path working // both in the filesystem, and through the web for links createThumbs("imageuploads/","imageuploads/thumbs/",100); function createGallery( $pathToImages, $pathToThumbs ) { //echo "Creating gallery.html <br />"; $output = "<html>"; $output .= "<head><title>Thumbnails</title></head>"; $output .= "<body>"; $output .= "<table cellspacing=\"0\" cellpadding=\"2\" width=\"500\">"; $output .= "<tr>"; // open the directory $dir = opendir( $pathToThumbs ); $counter = 0; // loop through the directory while (false !== ($filename = readdir($dir))) { // strip the . and .. entries out if ($filename != '.' && $filename != '..') { $output .= "<td valign=\"middle\" align=\"center\"><a href=\"{$pathToImages}{$filename}\">"; $output .= "<img src=\"{$pathToThumbs}{$filename}\" border=\"0\" />"; $output .= "</a></td>"; $counter += 1; if ( $counter % 4 == 0 ) { $output .= "</tr><tr>"; } } } // close the directory closedir( $dir ); $output .= "</tr>"; $output .= "</table>"; $output .= "</body>"; $output .= "</html>"; // open the file $fhandle = fopen( "gallery.html", "w" ); // write the contents of the $output variable to the file fwrite( $fhandle, $output ); // close the file fclose( $fhandle ); } // call createGallery function and pass to it as parameters the path // to the directory that contains images and the path to the directory // in which thumbnails will be placed. We are assuming that // the path will be a relative path working // both in the filesystem, and through the web for links createGallery("imageuploads/","imageuploads/thumbs/"); ?>
  8. <?php $_SESSION['username'] = $_GET['username']; if($_POST) { // In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead // of $_FILES. $uploaddir = 'path_to_dir'; $uploadfile = $uploaddir . basename($_FILES['userfile']['name']); $url = 'url_dir' . $_FILES['userfile']['name']; $filename = $_FILES['userfile']['name']; $filesize = $_FILES['userfile']['size']; $filetype = $_FILES['userfile']['type']; $uploaded_by = $_SESSION['username']; $categories = $_POST['categories']; if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { echo '<div class="maincontentheader"> <h2>' . ucwords($_SESSION['username']) . ', thank you for your upload!</h2> </div>'; echo "<p>File is valid, and was successfully uploaded.\n</p>"; } else { echo "<p>Possible file upload attack!\n</p>"; } echo '<p>Below is the information of the file you uploaded:</p>'; echo '<p> Name of File: ' . $filename . '</p>'; echo '<p> Type of File: ' . $filetype . '</p>'; echo '<p> Size of File: ' . $filesize . '</p>'; echo '<p> Categories: ' . $categories . '</p>'; $thumbq = "insert into thumbs (thumb_name) values ('$filename')"; $thumquery = mysql_query($thumbq) or die("ERROR: " . mysql_error()); if($_FILES['userfile']) { include "includes/sql.php"; $query = "insert into uploads (username, name, size, type, url, categories, downloaded_by) " . "values ('$uploaded_by', '$filename', '$filesize', '$filetype', '$url', '$categories', '')"; mysql_query($query) or die("ERROR: " . mysql_error()); echo '<p>File loaded into Database successfully!</p>'; } else { echo '<p>There was a problem with inserting the file into the database! Please try again!</p>'; } } else { echo '<div class="maincontentheader"> <h2>' . ucwords($_SESSION['username']) . ', use the form below to upload an image!</h2> </div> <p>Make sure to add categories to this image.</p> <p> </p> <p>Adding categories allows for the image to show up during an image search!</p> <p> </p> <p>Example Categories: Cat, Dog, Ocean, Older Male, Female, etc...</p> <p> </p> <p style="font-size: 80%"><b>Note: if you have more than one category please make sure to separate them by a comma!</b></p> <p> </p> <!-- The data encoding type, enctype, MUST be specified as below --> <form enctype="multipart/form-data" action="upload.php?username=' . $_SESSION['username'] . '" method="POST" name="uploadfile"> <!-- MAX_FILE_SIZE must precede the file input field --> <input type="hidden" name="MAX_FILE_SIZE" value="9999999" /> <!-- Name of input element determines name in $_FILES array --> <p>Image Categories: <input name="categories" type="text" /></p> <p> </p> <p>Upload this file: <input name="userfile" type="file" /></p> <p><input type="submit" value="Upload File" /></p> </form>'; } //on-th-fly thumbnail generator include "thumbtest.php"; ?> Now the weird thing it is reversed. It is inserting the data and then a blank field :/ it started doing this I moved the include "thumbtest.php" down to the bottom
  9. Ok, Here is my situation. I have a SQL query running to insert data into a table field, but when it does it inserts a blank field then inserts the data. Any suggestions?
  10. then why use the brackets vs not using them?
  11. Whats the difference between the two If.. Else Statements? if($var) echo "..."; else echo "???"; if($var) { echo "..."; } else { echo "???"; }
  12. How would I order a list of items out of a Database using the newest entry or even the newest timestamp? $sqlcount = "select * from uploads order by timestamp ASC limit 10";
  13. if(move_uploaded_file) { include "includes/sql.php"; $query = "insert into uploads (username, name, size, type, url, categories, downloaded_by) " . "values ('$uploaded_by', '$filename', '$filesize', '$filetype', '$url', '$categories', '')"; mysql_query($query) or die("ERROR: " . mysql_error()); echo '<p>File loaded into Database successfully!</p>'; } else { echo '<p>There was a problem with inserting the file into the database! Please try again!</p>'; } } else { echo '<div class="maincontentheader"> <h2>' . ucwords($_SESSION['username']) . ', use the form below to upload an image!</h2> </div> <p>Make sure to add categories to this image.</p> <p> </p> <p>Adding categories allows for the image to show up during an image search!</p> <p> </p> <p>Example Categories: Cat, Dog, Ocean, Older Male, Female, etc...</p> <p> </p> <p style="font-size: 80%"><b>Note: if you have more than one category please make sure to separate them by a comma!</b></p> <p> </p> <!-- The data encoding type, enctype, MUST be specified as below --> <form enctype="multipart/form-data" action="upload.php?username=' . $_SESSION['username'] . '" method="POST" name="uploadfile"> <!-- MAX_FILE_SIZE must precede the file input field --> <input type="hidden" name="MAX_FILE_SIZE" value="9999999" /> <!-- Name of input element determines name in $_FILES array --> <p>Image Categories: <input name="categories" type="text" /></p> <p> </p> <p>Upload this file: <input name="userfile" type="file" /></p> <p><input type="submit" value="Upload File" /></p> </form>'; } //On-the-fly thumbnail generator include "thumbtest.php"; $thumbq = mysql_query("insert into thumbs (thumb_name) " . "values ('$filename')");
  14. my sql statement is creating a blank field then inserting the data in the next field within the table. Any ideas what causes this?
  15. I am thinking I am just going have the script run everytime an image is uploaded. There won't be many users using this script, considering the user list is limited. Thanks for everyones help
  16. I have a script that will create thumbnails for me. Is there a way to set the script to run every time the directory is updated?
  17. gallery.html was created when the script ran
  18. I tried your script but It is displaying a blank page. like nothing loads in the iframe. This is going to sound like a newb question but, When you say $dir = opendir( $pathToImages ); do i need to put in the path or keep the var the same?
  19. can someone point me in the right direction on how to create thumbnails of images on the fly using php?
×
×
  • 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.