Jump to content

Alkimuz

Members
  • Posts

    45
  • Joined

  • Last visited

Everything posted by Alkimuz

  1. hmm.. it should not really be important what the rest of the code lookes like, the name of the picture should still just be stored within the database.. you do have code above this code to connect with your database right? and you also made a database with a table named 'test' with a field named cropimg? i changed a littlebit of the code and just for sure also added code to connect to a database... fill in the first 4 variables with your own databaseproperties EDIT: i just tested this part of the code on my website and i do get the name of the image within the database, so i hope it works for you too! [attachment deleted by admin]
  2. Tanks so much! :D also for the extra explanation
  3. EDIT: sorry, first time i forgot to place $date, changed it now EDIT2: made an other change, sorry for not being an expert and doing it good right away ok try this, i changed both files a little. the name of the file was assigned within the function in this way: strtolower($date).'.jpg'. i now assigned that name earlyer, so you can use it to store in your database and transported it within the array to the function, so it can be used there, hope it works! <?php include('dbConnection/dbConfig.php'); include('dbConnection/dbOpen.php'); include('func.php'); if($_GET['act'] == 'thumb'){ $date = md5(time()); $name = strtolower($date).'.jpg'; $arr = array( 'uploaddir' => 'uploads/', 'tempdir' => 'uploads/temp/', 'height' => $_POST['height'], 'width' => $_POST['width'], 'x' => $_POST['x'], 'y' => $_POST['y'], 'img_src' => $_POST['img_src'], 'thumb' => true, 'name' => $name, 'date' => $date ); resizeThumb($arr); //START OF SQL $SQL = "INSERT INTO test (cropimg) VALUES ('$name')"; if (!mysql_query($SQL,$conn)) { die('Error: ' . mysql_error()); } //END OF SQL exit; } elseif($_GET['act'] == 'upload'){ $big_arr = array( 'uploaddir' => 'uploads/big/', 'tempdir' => 'uploads/temp/', 'height' => $_POST['height'], 'width' => $_POST['width'], 'x' => 0, 'y' => 0 ); resizeImg($big_arr); } else { // } include('dbConnection/dbClose.php'); ?> and <?php function resizeImg($arr){ //you can change the name of the file here $date = $arr['date']; //////////// upload image and resize $uploaddir = $arr['uploaddir']; $tempdir = $arr['tempdir']; $temp_name = $_FILES['photo']['tmp_name']; //echo $temp_name; $img_parts = pathinfo($_FILES['photo']['name']); $new_name = strtolower($date.'.'.$img_parts['extension']); $ext = strtolower($img_parts['extension']); $allowed_ext = array('gif','jpg','jpeg','png'); if(!in_array($ext,$allowed_ext)){ echo '<p class="uperror">Please upload again. Only GIF, JPG and PNG files please.</p>'; exit; } $temp_uploadfile = $tempdir . $new_name; $new_uploadfile = $uploaddir . $new_name; // less than 1.3MB if($_FILES['photo']['size'] < 2097000 ){ if (move_uploaded_file($temp_name, $temp_uploadfile)) { // add key value to arr $arr['temp_uploadfile'] = $temp_uploadfile; $arr['new_uploadfile'] = $new_uploadfile; asidoImg($arr); unlink($temp_uploadfile); exit; } } else { echo '<p class="uperror">Please upload again. Maximum filesize is 1.3MB.</p>'; exit; } } function resizeThumb($arr){ $date = $arr['date']; $arr['temp_uploadfile'] = $arr['img_src']; $arr['new_uploadfile'] = $arr['uploaddir'].$arr['name']; asidoImg($arr); exit; } function asidoImg($arr){ include('asido/class.asido.php'); asido::driver('gd'); $height = $arr['height']; $width = $arr['width']; $x = $arr['x']; $y = $arr['y']; // process $i1 = asido::image($arr['temp_uploadfile'], $arr['new_uploadfile']); // fit and add white frame if($arr['thumb'] === true){ Asido::Crop($i1, $x, $y, $width, $height); } else{ Asido::Frame($i1, $width, $height, Asido::Color(255, 255, 255)); } // always convert to jpg Asido::convert($i1, 'image/jpg'); $i1->Save(ASIDO_OVERWRITE_ENABLED); $data = array( 'photo'=> $arr['new_uploadfile'] ); // echo $user_id; // delete old file echo $data['photo']; } ?>
  4. i guess that there is some kind of way that the pages are different from each other? you can use that difference to assign different names before the include and within the include refer to that with a variable for example, the pages are different by url and the urls are: website.com?page=1 and website.com?page=2 etc. you can ask that name and change it with: if ($_GET['page'] == '1') $title = 'The name of the first page'; if ($_GET['page'] == '2') $title = 'The name of the second page'; and within your include you place echo '<title>'.$title.'</title>'; something like this?
  5. i am a little confused, do you want to store only the thumbnail? Because this code makes two resizes, one thumbnail and one main picture, and uploads them, but with your SQL, you only seem interested in the thumbnail.. anyway, your code will not work as resizeThumb($arr) is no imagepath, but the function to process it you should place the imagename here in stead. this imagename is made on the functionpage. i would make this imagename in your maincode and than pass it on within the function.. can you specify: what do you want your code to do? because this code might do more than that, only upload your image and put it into a database? or also make two resizes, upload them both and put them both into a database?
  6. you should place the same name as the image is uploaded in your database, so you can get that name out of your database and show it on your website if i see it corectly, your image is stored as $new_name, so after $new_name is made, put it in your database: $sql="INSERT INTO tablename (photoname) VALUES ('$new_name')"; and where you want to show your picture, after getting it out of the database, place the directory + the photoname echo '<img src="'.$uploaddir.$row['photoname'].'">'; of course you can also store the directory + the name in the database, but would not recommend that as after deciding to put all the images in an other directory, you have a lot to correct hope it helps!
  7. i'm a little ashamed to asked something that is probably so easy, i tried to find the answer, but i am really a NOOB in javascript so i hope that i can ask you for a code that is ready to use.. i now have a code to delete an item in a website by pushing on a button. It goes to a new page wich has an SQL delete code. In short: echo '<a href="save.php?type=delete&item='.$item.'">delete</a> '; but now i really like to put a confirmation box between that, so after pushing the button, a message box appears asking: "Are you sure to delete this item?" and after clicking yes, it goes right away to that deletepage thanks very much in advance!
  8. wouw, thanks guys! i indeed accidentally deleted the first 'menu' in menuID but the answer is perfect! thanks again! :D
  9. just a little question, but hard to find an answer for: i have a variable with a lot of different possible values, and i want with some particular values run a script and with other not, i have the following code, which runs fine, but it looks so unnecessary long.. is it possible to shorten in down? if ($ID == 1 || $menuID ==5 || $menuID ==6 || $menuID ==7 || $menuID ==8 || $menuID ==9 || $menuID ==10 || $menuID ==21 || $menuID ==22 || $menuID ==23 || $menuID ==24 enz.. ) { code code code code }
  10. hahaha, WHOOT! after 3 hours of frustration i have found a way around it, with large data: <div style="border-left: solid #00bb00 1px;"> is showed wrong in firefox but the following works! (no clue why): <div style="border:solid #00bb00; border-width: 0 0 0 1px;"> my conclusion is that this is really a bug in firefox.. i'm shocked! hopefully my solution can help others with the same problem
  11. Hi, i am working on a family tree using the left border of div's to present the lines between father and children. The code worked perfectly, but after adding one more person, the longest border suddenly collapsed in firefox! in IE its still working. The border is only for a part visible in the middle of the site of the div.. The div is still totally present, if i add background-color, this is visible, but not the border.. I tested this on an other big amound of data and again, the border collapses.. so i'm pretty sure there is nothing wrong with the code.. I think firefox cant calculate the actual length because its to big? or something like this? Any experiances with this? Any ways to solve it or to work around this? thanks in advance! my site: http://www.davidvandiepen.nl/stamboom/new, look at the disapeared green line under the last green box, its visual for a part if you scroll down. maybe ive worked in the mean time on it, so it might show different than told, for an other example, go to: http://www.davidvandiepen.nl/stamboom.php, there should be a white border on the left side of it, now only vissible in the middle..
  12. thanks! both of you! amagondes for making me help to understand why it didnt work projectfear for the golden tip for making my code work! i didnt know the function copy, so know i do, it was not a hard job to change my not working code to a working one thanks again ^^
  13. you can show all the bookings with the code: while ($row = mysql_fetch_array($result)) { } this while loops through all the data stored in the database and shows it in the way that you put beween {}, so that would be the code i did write in the previous post. If you want to put it in a table, you can use the following: echo '<table><tr><td>dag<td>month<td>year<td>time'; while ($row = mysql_fetch_array($result)) { (all the code etc etc) echo '<tr><td>'$day.'<td>'.$month.'<td>'.$year.'<td>'.$slot; } </table>
  14. i think its easyer to not use integers for all the different dateparts, but just a datetime (thats one of the options in your database to store data) and than get it out of the database in the way you want with the option DATE_FORMAT. but anyway, it works in your way too, although it takes a lot of code to display it on your website, get it out of the database, change it to the info you want and put it in the order you want, for example: $result = mysql_query("SELECT * FROM table" ); $row = mysql_fetch_array($result); if($row['day'] == '0') {$day= 'monday';} elseif($row['day'] == '1') {$day= 'tuesday';} elseif($row['day'] == '2') {$day= 'wednesday';} elseif($row['day'] == '3') {$day= 'thursday';} etc if($row['month'] == '0') {$month= 'jan';} elseif($row['month'] == '1') {$month= 'feb';} elseif($row['month'] == '2') {$month= 'mar';} elseif($row['month'] == '3') {$month= 'apr';} etc etc echo 'you have booked on: '; echo $day.' '.$month.' '.$year.' on '.$slot;
  15. i have a code like that in my upload code for pictures, it goes as follows: // Does the file have the right MIME type? if ($_FILES[$filename]['type'] != 'image/pjpeg' AND $_FILES[$filename]['type'] != 'image/jpeg' AND $_FILES[$filename]['type'] != 'image/gif' AND $_FILES[$filename]['type'] != 'image/png' AND $_FILES[$filename]['type'] != 'image/wbmp') { echo 'the file you want to upload is no picture, please go back to try again'; exit; } i guess you can change that to mp3, mp2, mp1, wav and ogg
  16. you can set one by using the code: setcookie("name you wat to give to cookie", "the information you want to store in the cookie", the time you want the cookie to exist in seconds); so for example: $name = 'idire'; setcookie("UsersName", $name, time()+3600); you can read the cookie by using the code: $_COOKIE['Name of the cookie']; so for example echo 'hello '.$_COOKIE['UserName']; will show: hello idire good luck
  17. you can chance the date out of your database to any form you like with the function: DATE_FORMAT in your case: $result = mysql_query("SELECT date, DATE_FORMAT(date, '%d-%m-%Y ') as date FROM table" ) take a look at http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format
  18. Hey, i want to save an uploaded picture to two different locations, is that possible? if so, how? now, i let a user upload a picture and my code resizes the picture and stores it at a specific location, but i like to resize it for a second time and store that picture at a second location, but it seems that if i run the uploadcode twice, the original temporary sourcedata ( where $_FILES[$filename]['tmp_name'] points to) is deleted? the code i use at the moment is the following, any suggestions how i can expand it, or repeat it so that it resizes the original picture twice and stores it twice? function photoupload($filename, $source, $path, $name, $MaxX, $MaxY) { /*START PHOTOUPLOAD*/ if (trim($_FILES[$filename]['tmp_name']) == TRUE) { $destination = $path.$name.'-'.$_FILES[$filename]['name'] ; // Does the file have the right MIME type? if ($_FILES[$filename]['type'] != 'image/pjpeg' AND $_FILES[$filename]['type'] != 'image/jpeg' AND $_FILES[$filename]['type'] != 'image/gif' AND $_FILES[$filename]['type'] != 'image/png' AND $_FILES[$filename]['type'] != 'image/wbmp') { echo 'the file you want to upload is no photo, please go back to try again'; exit; } // Get current dimensions list($width_orig, $height_orig) = getimagesize($source); // Check if they are over their limit if ( ($width_orig > $MaxX) || ( $height_orig > $MaxY)) { if ($MaxX && ($width_orig < $height_orig)) { $MaxX = ($MaxY / $height_orig) * $width_orig; } else { $MaxY = ($MaxX / $width_orig) * $height_orig; } // Resample voorbereiden $image_p = imagecreatetruecolor($MaxX, $MaxY); $image_type = strtolower( substr($destination, strrpos( $destination, '.' )) ); switch( $image_type ) { case '.gif' : $image = imagecreatefromgif($source); break; case '.jpg' : $image = imagecreatefromjpeg($source); break; case '.jpeg': $image = imagecreatefromjpeg($source); break; case '.png' : $image = imagecreatefrompng($source); break; case '.bmp' : $image = imagecreatefromwbmp($source); break; } // Resample de afbeelding imagecopyresampled($image_p, $image, 0, 0, 0, 0, $MaxX, $MaxY, $width_orig, $height_orig); // Output switch( $image_type) { case '.gif' : imagegif($image_p, $source, 100); break; case '.jpg' : imagejpeg($image_p, $source, 100); break; case '.jpeg' : imagejpeg($image_p, $source, 100); break; case '.png' : imagepng($image_p, $source, 100); break; case '.bmp' : image2wbmp($image_p, $source, 100);break; } move_uploaded_file ( $source, $destination ); } else { // Image is ok, just move it to the new location move_uploaded_file ( $source, $destination ); } return 0; } /*END PHOTOUPLOAD*/ }
  19. You guys Rock!! first and third solution work indeed exelent! many thanks, i can continue working now
  20. probably a noob-question, but i have to ask after 2 hours trying to find out for myself.. i know how to subtract a month from the date of today and present it like mm-yyyy: date ("m-Y", mktime (0, 0, 0, date("m") - 1, date("d"), date("Y"))) but how to subtract a month from an other date that today?? so for example, my input is: $date = 01-2003 and i want an output like: $lastmonth = 12-2002 how to get there? thanks so mutch for any help!
×
×
  • 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.