Jump to content

glassfish

Members
  • Posts

    119
  • Joined

  • Last visited

Everything posted by glassfish

  1. Code: <?php /* * HASHTAGS */ if(isset($_POST['hashtag0'])) { $hashtag0 = $_POST['hashtag0']; } if(isset($_POST['hashtag1'])) { $hashtag1 = $_POST['hashtag1']; } if(isset($_POST['hashtag2'])) { $hashtag2 = $_POST['hashtag2']; } if(isset($_POST['hashtag3'])) { $hashtag3 = $_POST['hashtag3']; } if(isset($_POST['hashtag4'])) { $hashtag4 = $_POST['hashtag4']; } if(isset($_POST['hashtag5'])) { $hashtag5 = $_POST['hashtag5']; } if(isset($_POST['hashtag6'])) { $hashtag6 = $_POST['hashtag6']; } if(isset($_POST['hashtag7'])) { $hashtag7 = $_POST['hashtag7']; } if(isset($_POST['hashtag8'])) { $hashtag8 = $_POST['hashtag8']; } if(isset($_POST['hashtag9'])) { $hashtag9 = $_POST['hashtag9']; } if(isset($_POST['hashtag10'])) { $hashtag10 = $_POST['hashtag10']; } if(isset($_POST['hashtag11'])) { $hashtag11 = $_POST['hashtag11']; } if(isset($_POST['hashtag12'])) { $hashtag12 = $_POST['hashtag12']; } ?> <?php // Stores the hashtags taken from the form inside an array. $hashtags = array($hashtag0, $hashtag1, $hashtag2, $hashtag3, $hashtag4, $hashtag5, $hashtag6, $hashtag7, $hashtag8, $hashtag9, $hashtag10, $hashtag11, $hashtag12 ); ?> Basically, the script checks if the "$_POST['']" variable from the form is set and then it stores the "given" "values" from the form inside an array. I tried it with this: <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <?php for($i = 0; $i < 12; $i++){ echo "<input type='text' name='hashtag" . $i . "' />"; } ?> <input type="submit" name="submit" /> </form> <?php if(isset($_POST['submit'])){ for($i = 0; $i < 12; $i++) { if(isset($_POST['hashtag$i'])){ $hashtags = array($_POST['hashtag$i']); } } print_r($hashtags); } ?> With this example I get the following notice: Notice: Undefined variable: hashtags in C:\xampp\htdocs\hashtags\index.php on line 19 It points to "print_r()". I would appreciate the suggestions.
  2. Addendum: So, basically this is how I have the script. I have commented the "If statement" with the "$_GET['thread_id']" variable out. <?php include($_SERVER['DOCUMENT_ROOT'] . "/gallerysite/header.php"); ?> <?php include($_SERVER['DOCUMENT_ROOT'] . "/gallerysite/connect.php"); ?> <?php //if(isset($_GET['thread_id'])) { $tqs = "SELECT * FROM `thread` WHERE `id` = '" . $_GET['thread_id'] . "'"; $tqr = mysqli_query($dbc, $tqs) or die(mysqli_error($dbc)); $row = mysqli_fetch_assoc($tqr); ?> <div class="div"> <h1>Admin Modify</h1> <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input type="text" name="title" value="<?php echo $row['title']; ?>"/><br/> <textarea type="text" name="caption"><?php echo $row['caption']; ?></textarea> <input type="submit" name="admin_update" value="Update" /> </form> </div> <?php //} ?> <?php // This prints e.g.: // 47 echo "The Thread ID: "; echo $_GET['thread_id']; if(isset($_POST['admin_update'])){ $tqs = "UPDATE `thread` SET `title` = 'testing', `caption` = 'testing' WHERE `id` = '" . $_GET['thread_id'] . "'"; $tqr = mysqli_query($dbc, $tqs) or die(mysqli_error($dbc)); echo "The query: " . $tqs; } ?> <?php include($_SERVER['DOCUMENT_ROOT'] . "/gallerysite/footer.php"); ?> After clicking on the submit button I am getting the following errors: Notice: Undefined index: thread_id in C:\xampp\htdocs\gallerysite\admin_modify.php on line 15 Notice: Undefined index: thread_id in C:\xampp\htdocs\gallerysite\admin_modify.php on line 38 Notice: Undefined index: thread_id in C:\xampp\htdocs\gallerysite\admin_modify.php on line 41 The SQL query printed on screen: UPDATE `thread` SET `title` = 'testing', `caption` = 'testing' WHERE `id` = '' @Zane I am becoming confused, why "thread_id" is even becomes not set anymore.(?) It happens after the "submit button" has gotten clicked. EDIT: I stored "thread_id" in the form as a hidden field, and then I go over to update the table with "$_POST['thread_id']". This works. <div class="div"> <h1>Admin Modify</h1> <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input type="hidden" name="thread_id" value="<?php echo $_GET['thread_id']; ?>"/> <input type="text" name="title" value="<?php echo $row['title']; ?>"/><br/> <textarea type="text" name="caption"><?php echo $row['caption']; ?></textarea> <input type="submit" name="admin_update" value="Update" /> </form> </div> Thanks for the answers!
  3. Addendum: I tried the following and it worked: The Script: <?php // This prints e.g.: // 47 echo "The Thread ID: "; echo $_GET['thread_id']; //if(isset($_POST['admin_update'])){ $tqs = "UPDATE `thread` SET `title` = 'testing', `caption` = 'testing' WHERE `id` = '46'"; $tqr = mysqli_query($dbc, $tqs) or die(mysqli_error($dbc)); echo "The query: " . $tqs; //} } ?> I also tried the following and it worked: <?php // This prints e.g.: // 47 echo "The Thread ID: "; echo $_GET['thread_id']; //if(isset($_POST['admin_update'])){ $tqs = "UPDATE `thread` SET `title` = 'testing', `caption` = 'testing' WHERE `id` = '" . $_GET['thread_id'] . "'"; $tqr = mysqli_query($dbc, $tqs) or die(mysqli_error($dbc)); echo "The query: " . $tqs; //} } ?> Printed on Screen: The query: UPDATE `thread` SET `title` = 'testing', `caption` = 'testing' WHERE `id` = '46' Note: The "submit button" in the "if statement" is commented out. It looks like there may have been an issue with the POST method.(?) EDIT: When I bring the "submit button" with the "if statement" back in it does not work anymore, though I am not seeing where the issue is with this. EDIT 2: Okay I am getting the following error message: Undefined index: thread_id Perhaps, this does happen when the URL changes to:(?) http://localhost/gallerysite/admin_modify.php Though, this does happen, after the "submit button" has gotten clicked.(?) So, basically I click on the "submit button" and the "$_GET['thread_id']" variable is becoming not set?
  4. Thanks for the response! The URL is at first: http://localhost/gallerysite/admin_modify.php?thread_id=46 I tried to print the SQL statement on screen like in this following example: if(isset($_POST['admin_update'])){ $tqs = "UPDATE `thread` SET `title` = '" . $_POST['title'] . "', `caption` = '" . $_POST['caption'] . "' WHERE `id` = '" . $_GET['thread_id'] . "'"; $tqr = mysqli_query($dbc, $tqs) or die(mysqli_error($dbc)); echo "The query: " . $tqs; } When I click on the "submit button" ("admin_update") then the URL turns into the following: http://localhost/gallerysite/admin_modify.php And I am getting a blank page, the "header", "footer" and the "stylesheet" is still there, though the SQL statement does not get printed on screen. Any suggestions how to have the "printing on screen" of the SQL statement work out with this script?
  5. The Script: <?php include($_SERVER['DOCUMENT_ROOT'] . "/gallerysite/header.php"); ?> <?php include($_SERVER['DOCUMENT_ROOT'] . "/gallerysite/connect.php"); ?> <?php if(isset($_GET['thread_id'])) { $tqs = "SELECT * FROM `thread` WHERE `id` = '" . $_GET['thread_id'] . "'"; $tqr = mysqli_query($dbc, $tqs) or die(mysqli_error($dbc)); $row = mysqli_fetch_assoc($tqr); ?> <div class="div"> <h1>Admin Modify</h1> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input type="text" name="title" value="<?php echo $row['title']; ?>"/><br/> <textarea type="text" name="caption"><?php echo $row['caption']; ?></textarea> <input type="submit" name="admin_update" value="Update" /> </form> </div> <?php // This prints e.g.: // 47 echo "The Thread ID: "; echo $_GET['thread_id']; if(isset($_POST['admin_update'])){ $tqs = "UPDATE `thread` SET `title` = '" . $_POST['title'] . "', `caption` = '" . $_POST['caption'] . "' WHERE `id` = '" . $_GET['thread_id'] . "'"; $tqr = mysqli_query($dbc, $tqs) or die(mysqli_error($dbc)); } } ?> <?php include($_SERVER['DOCUMENT_ROOT'] . "/gallerysite/footer.php"); ?> I do not see why this is not working. The "UPDATE" SQL statement has worked without the "WHERE" part and modified all of the posts. (With this the database connection works too.) Though, this statement does work in PhpMyAdmin: UPDATE `thread` SET `title` = 'testing', `caption` = 'testing' WHERE `id` = '47'; I added the "WHERE" part to the script and now it is not modifying the text in the table anymore, basically the "updates" do not happen. What could be the issue here? Any suggestions are much appreciated. Also, I have used this way of "syntax style" in PHP, perhaps somebody could be modifying the "UPDATE" SQL statement into a different syntax style so I can try it out, I would much appreciate it. I would also like to ask how the "syntax style" I have used is and if it can be better than this?
  6. I saw this in the PHP documentation: SERVER_ADDR 127.0.0.1 SERVER_NAME localhost SERVER_SOFTWARE Apache/2.2.22 (Win64) PHP/5.3.13 SERVER_PROTOCOL HTTP/1.1 ... REMOTE_ADDR 127.0.0.1 Is there a way to get specifically the remote address in this way myself?
  7. This script ... <?php echo "Your IP Address: <br/>"; print_r($_SERVER['REMOTE_ADDR']); ?> ... prints: ::1 I am looking to have the IP address from which the site is viewed printed on screen. What is the issue, here, with the script I have? I have been trying this on localhost and I am using XAMPP.
  8. The Script: <?php include("connect.php"); ?> <?php echo "<h1>The Hashtag: </h1>"; if(isset($_GET['hashtag'])){ echo $_GET['hashtag']; } // Select the ID of the given hashtag from the "hashtags" table. $tqs = "SELECT `id` FROM `hashtags` WHERE `hashtag` = '" . $_GET['hashtag'] . "'"; $tqr = mysqli_query($dbc, $tqs) or die(mysqli_error($dbc)); $row = mysqli_fetch_assoc($tqr); // This prints e.g.: // 100 echo "<br/><br/>"; print_r($row['id']); // Select the threads from the "thread" table which contains the hashtag ID number. $tqs_two = "SELECT * FROM `thread` WHERE `hashtag_id` IN ('" . $row['id'] . "')"; $tqr_two = mysqli_query($dbc, $tqs_two) or die(mysqli_error($dbc)); $row_two = mysqli_fetch_assoc($tqr_two); echo "<br/><br/>"; print_r($row_two); ?> The script should select the rows by that ID number of the hashtag. It should look in the "hashtag_id" column of the table and see if that ID number can be found there, if it can be found there, then it should select that row. The ID numbers are inside that "hashtag_id" column separated by commas. Example: 98, 99, 100 My Question: How to do the SQL query so it selects the rows by the hashtag ID number?
  9. Thanks for the answer. This is how I have gotten it to work: <?php $string = "#xbox"; echo "<a href='search.php?hashtag=" . urlencode($string) . "'>#xbox</a>"; echo "<h1>The Hashtag: </h1>"; if(isset($_GET['hashtag'])){ echo $_GET['hashtag']; } ?>
  10. The Script: <?php echo "<h1>The Hashtag: </h1>"; echo $_GET['hashtag']; ?> An example for the URL on localhost: /search.php?hashtag=#xbox If I am not using the number sign, then the word "xbox" does get printed on screen, if I do use the number sign then the hashtag "#xbox" does not get printed on screen. Any suggestions on how to do this?
  11. Addendum: I have gotten this to work by creating the array (first) "$fetch_array = array();" outside of the for loop, the printing of the array would then have to happen outside of the for loop as well.
  12. Placing this outside of the for loop... print_r($fetch_array); .. prints: Array ( [0] => 560 ) It prints the last added ID number. Here I am asking, how can I have the other ID numbers too? I thought maybe the "array" has to be printed outside of the for loop to have all ID numbers inside one array. OxMatt, your suggestions prints the following: $values = rtrim(implode(', ', $fetch_array)); // Should print, "542, 543, 544" no whitespace print_r($values); 561 562 563 Do you have another suggestion?
  13. OxMatt, your example inserts the ID numbers one row after the other. For example: Row 1: Title, Caption, ", Hashtags, Date Created Row 2: ", ", 557, ", " Row 3: ", ", 558, ", " I am looking to have this data which gets printed by the script the way it is currently ... Array ( [0] => 542 ) Array ( [0] => 543 ) Array ( [0] => 544 ) ... inside one array: Array ( [0] => 542 [1] => 543 [2] => 544 ) Then I would be looking to use the "implode()" function to get this: 542, 543, 544 Barand, the data is referenced to a "thread" (which gets created), I thought this may be the way to do it?
  14. The Script: $desired_width = 110; if (isset($_POST['submit'])) { $j = 0; //Variable for indexing uploaded image for ($i = 0; $i < count($_FILES['file']['name']); $i++) {//loop to get individual element from the array $target_path = $_SERVER['DOCUMENT_ROOT'] . "/gallerysite/multiple_image_upload/uploads/"; //Declaring Path for uploaded images $validextensions = array("jpeg", "jpg", "png"); //Extensions which are allowed $ext = explode('.', basename($_FILES['file']['name'][$i]));//explode file name from dot(.) $file_extension = end($ext); //store extensions in the variable $new_image_name = md5(uniqid()) . "." . $ext[count($ext) - 1]; $target_path = $target_path . $new_image_name;//set the target path with a new name of image $j = $j + 1;//increment the number of uploaded images according to the files in array if (($_FILES["file"]["size"][$i] < 100000) //Approx. 100kb files can be uploaded. && in_array($file_extension, $validextensions)) { if (move_uploaded_file($_FILES['file']['tmp_name'][$i], $target_path)) {//if file moved to uploads folder echo $j. ').<span id="noerror">Image uploaded successfully!.</span><br/><br/>'; $tqs = "INSERT INTO images (`original_image_name`, `image_file`, `date_created`) VALUES ('" . $_FILES['file']['name'][$i] . "', '" . $new_image_name . "', now())"; $tqr = mysqli_query($dbc, $tqs); // Select the ID numbers of the last inserted images and store them inside an array. // Use the implode() function on the array to have a string of the ID numbers separated by commas. // Store the ID numbers in the "image_file_id" column of the "thread" table. $tqs = "SELECT `id` FROM `images` WHERE `image_file` IN ('$new_image_name')"; $tqr = mysqli_query($dbc, $tqs) or die(mysqli_error($dbc)); $fetch_array = array(); $row = mysqli_fetch_array($tqr); $fetch_array[] = $row['id']; /* * This prints e.g.: Array ( [0] => 542 ) Array ( [0] => 543 ) Array ( [0] => 544 ) */ print_r($fetch_array); // Goes over to create the thumbnail images. $src = $target_path; $dest = $_SERVER['DOCUMENT_ROOT'] . "/gallerysite/multiple_image_upload/thumbs/" . $new_image_name; make_thumb($src, $dest, $desired_width); } else {//if file was not moved. echo $j. ').<span id="error">please try again!.</span><br/><br/>'; } } else {//if file size and file type was incorrect. echo $j. ').<span id="error">***Invalid file Size or Type***</span><br/><br/>'; } } } Hey, sorry that I am posting this darn image upload script again, I have this almost finished and I am not looking to ask more questions when it comes to this script specifically. With the script above I have that part where the script should store the ID numbers (the auto_increment column of the table) of the image files inside of one array and then the "implode()" function would get used on the array and then the ID numbers would get inserted into the "image_file_id" column of the "thread" table. As you can see at the above part the script prints the following: Array ( [0] => 542 ) Array ( [0] => 543 ) Array ( [0] => 544 ) And I am looking to insert into the column of the table the following: 542, 543, 544 I thought of re-writing the whole image upload script since this happens inside the for loop, though I thought maybe I could be having this done with the script as it is right now. Any suggestions on how to do this?
  15. The Script: <form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>"> <input type="text" name="hashtags" /> <input type="submit" name="submit" /> </form> <?php include("connect.php"); ?> <?php if(isset($_POST['submit'])){ $hashtags = explode(", ", $_POST['hashtags']); for($i= 0; $i < count($hashtags); $i++){ $tqs = "SELECT `id` FROM `hashtags_two` WHERE `hashtags` = '" . $hashtags[$i] . "'"; $tqr = mysqli_query($dbc, $tqs) or die(mysqli_error($dbc)); } $fetch_array = array(); while($row = mysqli_fetch_array($tqr)){ $fetch_array[] = $row['id']; } } Hey, sorry for these fundamental array questions lately, I am not going to ask much more when it comes to this. The hashtags come from the submit form (separated by commas) and get stored inside an array with the "explode()" function. The script should select the ID numbers of the hashtags from the table. With the script above only the last row gets inserted into $fetch_array inside the while loop. When the $fetch_array variable is printed on screen then only one ID number can be seen inside the array: Array ( [0] => 24 ) How can I have the other ID numbers too?
  16. Thanks a lot! It works. I am glad it works so great! So basically, does SQL take over the checking if there is an "entry" already existing? Before inserting I only check for the existing number of rows with "mysqli_num_rows()".
  17. The Script: <form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>"> <input type="text" name="hashtags" /> <input type="submit" name="submit" /> </form> <?php if(isset($_POST['submit'])){ $hashtags = explode(", ", $_POST['hashtags']); // Prints e.g.: Array ( [0] => #tag1 [1] => #tag2 [2] => #tag3 [3] => #tag4 ) print_r($hashtags); } ?> This gets inserted into the input field: #tag1, #tag2, #tag3, #tag4 I am looking to check if any of the hashtags inside the array already exist in the database, if it does not exists it should create the new ones in the table. I know how to do this if all do not exists in the array and then it goes over to the MySQL query and inserts all of them. My Question Is: How to insert only the ones which do not exists out of the array, so the ones which do exists do not get inserted again into the table?
  18. I did not think you would see this as "name integrity". Actually, I thought, perhaps there are alternative ways. With the way you suggested I was not sure if it still "works out" when the traffic is high.
  19. Thanks for the answer. I am wondering, if there are a lot of images and the website has a "higher" traffic would that still work out? I am actually more wondering if it would "work out" or if problems would occur?
  20. The script for creating a new file name for the image: $validextensions = array("jpeg", "jpg", "png"); //Extensions which are allowed $ext = explode('.', basename($_FILES['file']['name'][$i]));//explode file name from dot(.) $file_extension = end($ext); //store extensions in the variable $new_image_name = md5(uniqid()) . "." . $ext[count($ext) - 1]; $target_path = $target_path . $new_image_name;//set the target path with a new name of image The script creates a new file like: f6c9b8d9db05366c3504210cded9ddb2.jpg and moves the file to the "uploads" folder. And then the script also creates a thumbnail with the same file name and moves the file to the "thumbs" folder. The issue I am having is that the same ID code could happen again for a different image in the database, thus I would be calling a different original sized image than the thumbnail image. My question is: How to avoid this issue of the same ID code has happened again for a different file. What is the proper way to reference the anchor tag of the thumbnail image to its actual original sized image? With the script I have the thumbnail image would be coming from the "thumbs" folder and the anchor tag would get referenced to the "uploads" folder to get the original sized image.
  21. /* create the physical thumbnail image to its destination */ I did not think that part needs a file name, I thought $virtual_image contains the filename already, and that part you quoted is basically the destination. Or imagejpeg(); works differently than I thought, so basically at that first spot it is the resizing and at the second spot moving the file to the destination. Both spots with the file name? I will try it out in a minute. EDIT: Oops, I may have misunderstood the script (or also imagejpeg()) trying this has worked: $dest = $_SERVER['DOCUMENT_ROOT'] . "/gallerysite/multiple_image_upload/thumbs/" . $new_image_name; Thanks a lot!
  22. The file name is there too, as you see on this line: The script uses javascript for multiple image upload.(?) When I try to move the "function definition" out of the loop I still get the same problem. My question to this part of one error message would be: failed to open stream: Invalid argument What type of reasons could there be so that the argument is invalid? Should I try "to force" unchecking the "read-only" option in Windows? Would I be able to uncheck the "read-only" option in Linux, for ex when using XAMPP and the folder is set "read-only"
  23. The Script: <?php if (isset($_POST['submit'])) { $j = 0; //Variable for indexing uploaded image $target_path = $_SERVER['DOCUMENT_ROOT'] . "/gallerysite/multiple_image_upload/uploads/"; //Declaring Path for uploaded images for ($i = 0; $i < count($_FILES['file']['name']); $i++) {//loop to get individual element from the array $validextensions = array("jpeg", "jpg", "png"); //Extensions which are allowed $ext = explode('.', basename($_FILES['file']['name'][$i]));//explode file name from dot(.) $file_extension = end($ext); //store extensions in the variable $new_image_name = md5(uniqid()) . "." . $ext[count($ext) - 1]; $target_path = $target_path . $new_image_name;//set the target path with a new name of image $j = $j + 1;//increment the number of uploaded images according to the files in array if (($_FILES["file"]["size"][$i] < 100000) //Approx. 100kb files can be uploaded. && in_array($file_extension, $validextensions)) { if (move_uploaded_file($_FILES['file']['tmp_name'][$i], $target_path)) {//if file moved to uploads folder echo $j. ').<span id="noerror">Image uploaded successfully!.</span><br/><br/>'; for ($i = 0; $i < count($_FILES['file']['name']); $i++) { $tqs = "INSERT INTO images (`original_image_name`, `image_file`, `date_created`) VALUES ('" . $_FILES['file']['name'][$i] . "', '" . $new_image_name . "', now())"; $tqr = mysqli_query($dbc, $tqs); } // To create the thumbnails. function make_thumb($src, $dest, $desired_width) { /* read the source image */ $source_image = imagecreatefromjpeg($src); $width = imagesx($source_image); $height = imagesy($source_image); /* find the "desired height" of this thumbnail, relative to the desired width */ $desired_height = floor($height * ($desired_width / $width)); /* create a new, "virtual" image */ $virtual_image = imagecreatetruecolor($desired_width, $desired_height); /* copy source image at a resized size */ imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $width, $height); /* create the physical thumbnail image to its destination */ imagejpeg($virtual_image, $dest); } $src = $target_path; $dest = $_SERVER['DOCUMENT_ROOT'] . "/gallerysite/multiple_image_upload/thumbs/"; $desired_width = 100; make_thumb($src, $dest, $desired_width); } else {//if file was not moved. echo $j. ').<span id="error">please try again!.</span><br/><br/>'; } } else {//if file size and file type was incorrect. echo $j. ').<span id="error">***Invalid file Size or Type***</span><br/><br/>'; } } } ?> With this: $dest = $_SERVER['DOCUMENT_ROOT'] . "/gallerysite/multiple_image_upload/thumbs/"; I get this error message: Warning: imagejpeg(C:/xampp/htdocs/gallerysite/multiple_image_upload/thumbs/): failed to open stream: No such file or directory in C:\xampp\htdocs\gallerysite\multiple_image_upload\upload.php on line 49 With this: $dest = "http://localhost/gallerysite/multiple_image_upload/thumbs/"; I get this error message: Warning: imagejpeg(http://localhost/gallerysite/multiple_image_upload/thumbs/): failed to open stream: HTTP wrapper does not support writeable connections in C:\xampp\htdocs\gallerysite\multiple_image_upload\upload.php on line 49 When I try deleting the "thumbs" folder and then try to upload an image, then I get this error message: Warning: imagejpeg(C:/xampp/htdocs/gallerysite/multiple_image_upload/thumbs/): failed to open stream: Invalid argument in C:\xampp\htdocs\gallerysite\multiple_image_upload\upload.php on line 49 The spot of line 49 is this, at the spot where the script creates the thumbnails: /* create the physical thumbnail image to its destination */ imagejpeg($virtual_image, $dest); } Also, with this part right here I am not getting an error message, which means that this part works fine in comparison: $target_path = $_SERVER['DOCUMENT_ROOT'] . "/gallerysite/multiple_image_upload/uploads/"; //Declaring Path for uploaded images The script itself works fine. The script also uses javascript for multiple image upload. I am using XAMPP. The folder "thumbs" is set to "read-only", when I try to uncheck the "read-only" option in the properties in Windows then it sets itself back again to "read-only". Then again, the script works fine when it comes to the "uploads" folder. This is mentioned in comparison to the "thumbs" folder. Any suggestions on how to solve this? EDIT: I am wondering if I would have issue that the option sets itself back again with Linux?
  24. Here I found this script: function make_thumb($src, $dest, $desired_width) { /* read the source image */ $source_image = imagecreatefromjpeg($src); $width = imagesx($source_image); $height = imagesy($source_image); /* find the "desired height" of this thumbnail, relative to the desired width */ $desired_height = floor($height * ($desired_width / $width)); /* create a new, "virtual" image */ $virtual_image = imagecreatetruecolor($desired_width, $desired_height); /* copy source image at a resized size */ imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $width, $height); /* create the physical thumbnail image to its destination */ imagejpeg($virtual_image, $dest); } I found it at: http://davidwalsh.name/create-image-thumbnail-php Can this script be modified so all three file extensions can be used? Or I could be using this script three times? I will try that in a minute. Thanks for the answer so far.
×
×
  • 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.