luismc2007 Posted May 23, 2013 Share Posted May 23, 2013 Hi, good morning. I have this code attached that is almost finished ready to work... ( sorry, is coded in spanish language ) But, at the end I have an error and don´t know how to fix... I´m, trying to copy and save the new image created "$final" with a new name "$lapeque", but doesn´t work. ( At comment: //PASO LA IMAGEN CREADA PEQUEÑA Y LA GRABO EN LA CARPETA DESTINOFINAL ) This code is without errors and runs to the end "echo[FIN]". Any idea?? Can you help me? please. Thanks a lot. Regards resizer.php. Quote Link to comment https://forums.phpfreaks.com/topic/278312-almost-finished-one-error-help-please/ Share on other sites More sharing options...
Love2c0de Posted May 23, 2013 Share Posted May 23, 2013 Good morning luismc2007, Can you post your error in English please? Kind regards, L2c. Quote Link to comment https://forums.phpfreaks.com/topic/278312-almost-finished-one-error-help-please/#findComment-1431775 Share on other sites More sharing options...
DaveyK Posted May 23, 2013 Share Posted May 23, 2013 In addition, show relevant code in code blocks rather than posting the file, please! Code tags are identified by the "<>" icon when adding a post! Quote Link to comment https://forums.phpfreaks.com/topic/278312-almost-finished-one-error-help-please/#findComment-1431777 Share on other sites More sharing options...
luismc2007 Posted May 23, 2013 Author Share Posted May 23, 2013 Hi: Yes, this is the code and echos in english, sorry and thanks for everybody <?php if ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "<br>"; }else { echo "File uploades: " . $_FILES["file"]["name"] . "<br>"; echo "Type: " . $_FILES["file"]["type"] . "<br>"; echo "Weight: " . ($_FILES["file"]["size"] / 1024) . " kB<br>"; } $archivo=$_SERVER['DOCUMENT_ROOT']."/test/arriba/".$_FILES["file"]["name"];echo "The file is: $archivo<br>"; echo "Copying file in destiny<br>";move_uploaded_file($_FILES["file"]["tmp_name"], $archivo);echo "Fichero imagen copiado<br>"; //Get the size of the original image list($ancho,$alto)=getimagesize($archivo); $anchooriginal=$ancho;echo "Original width: $anchooriginal<br>"; $altooriginal=$alto;echo "OriginalHeight: $altooriginal<br>"; // What is the image...$separo = explode( '.', strtolower($archivo) );$nombre = $separo[0];$extension = $separo[1]; echo "Name: $nombre<br>";echo "Extension: $extension<br>"; //My Final size for thumb$ancho_final="200";$alto_final="150"; // Create a new jpg image$imagen_src = imagecreatefromjpeg( $archivo );echo "ok, new image created in jpg format<br>"; //scaling and calculating size of image$escala_1=1;$escala_2=1;$escala_1=$ancho_final/$anchooriginal;$escala_2=alto_final/$altooriginal; echo "New Sizes: $escala_1, $escala_2 <br>"; //Let see if vertical or horizontal if ( $altooriginal > $anchooriginal ) { $escala_1 = $escala_2; } echo"Ok, scaling complete vertical-horizontal<br>"; // scaling $horizontal=ceil( $anchooriginal * $escala_1 );$vertical=ceil( $altooriginal * $escala_1 ); echo"The new scale is: $horizontal, $vertical<br>"; //create new image$final=imagecreatetruecolor ( $horizontal, $vertical ); echo"The new image is created<br>"; //copying the new image into teh new small image imagecopyresized ( $final, $imagen_src, 0, 0, 0, 0, $horizontal, $vertical, imagesx($imagen_src), imagesy($imagen_src) ); echo"Copied<br>"; $destinofinal=$_SERVER['DOCUMENT_ROOT']."/test/arriba/";echo "Copying file into final destiny: $destinofinal<br>"; //The new name for thumb $cadenapeque="p.jpg";$extraigo=substr($final,0,-4);$lapeque=$extraigo.$cadenapeque;echo "The thumb is: $lapeque<br>"; //creatingimagejpeg($final,$lapeque); //The thumb that I want to copy and save in the server copy($lapeque, $destinofinal);echo "Image saved in destiny<br>"; echo"closing...<br>"; imagedestroy ($final); echo"END<br>"; ?> I think my error is around this comment line: //The thumb that I want to copy and save in the server Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/278312-almost-finished-one-error-help-please/#findComment-1431781 Share on other sites More sharing options...
jazzman1 Posted May 23, 2013 Share Posted May 23, 2013 Put down the error_reporting(-1) on the top of that script and let us know if you get some error(s) in English Is it a windows or an unix machine? Quote Link to comment https://forums.phpfreaks.com/topic/278312-almost-finished-one-error-help-please/#findComment-1431795 Share on other sites More sharing options...
luismc2007 Posted May 23, 2013 Author Share Posted May 23, 2013 Hi. I just do that, I put that line at the beggining of the file and execute in the server.. no errors. :-) Maybe a clue. I receive this from an echo..... The thumb is: Resource ip.jpg Can be here the problem? HJow to fix? thanks. Quote Link to comment https://forums.phpfreaks.com/topic/278312-almost-finished-one-error-help-please/#findComment-1431796 Share on other sites More sharing options...
jazzman1 Posted May 23, 2013 Share Posted May 23, 2013 Try with this: ini_set("display_errors", true); error_reporting(-1); Quote Link to comment https://forums.phpfreaks.com/topic/278312-almost-finished-one-error-help-please/#findComment-1431810 Share on other sites More sharing options...
jazzman1 Posted May 23, 2013 Share Posted May 23, 2013 When I run your script into my server I got next errors: 1. Notice: Use of undefined constant alto_final - assumed 'alto_final' in .... you're using - $escala_2=alto_final/$altooriginal (don't forget a dollar sign) 2. Warning: substr() expects parameter 1 to be string, resource given in ... 3. Warning: copy(): The second argument to copy() function cannot be a directory in ... Double check the script and redesign it, also use a code tags next time, please! Quote Link to comment https://forums.phpfreaks.com/topic/278312-almost-finished-one-error-help-please/#findComment-1431813 Share on other sites More sharing options...
luismc2007 Posted May 23, 2013 Author Share Posted May 23, 2013 Oh, Dollar sign... jeje.. just forget it and don´t see it. :-) (sorry) now is ok... $escala_1=$ancho_final/$anchooriginal; $escala_2=$alto_final/$altooriginal; About the substr() function.... I think $final (first argument) is the "name" of the image that I create... or not? What I´m doing wrong with this? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/278312-almost-finished-one-error-help-please/#findComment-1431826 Share on other sites More sharing options...
jazzman1 Posted May 23, 2013 Share Posted May 23, 2013 About the substr() function.... I think $final (first argument) is the "name" of the image that I create... or not? What I´m doing wrong with this? You have to know what type of value expect to be the $final variable. Check : echo gettype($final); Quote Link to comment https://forums.phpfreaks.com/topic/278312-almost-finished-one-error-help-please/#findComment-1431828 Share on other sites More sharing options...
luismc2007 Posted May 23, 2013 Author Share Posted May 23, 2013 Ok, perfect. I´ll try it. Thank you very much for your help... (php is a complicated mistery for me right now, i´m starting to program now...) Quote Link to comment https://forums.phpfreaks.com/topic/278312-almost-finished-one-error-help-please/#findComment-1431844 Share on other sites More sharing options...
Love2c0de Posted May 24, 2013 Share Posted May 24, 2013 Good morning Luis, Did you manage to get it working? Kind regards, L2c. Quote Link to comment https://forums.phpfreaks.com/topic/278312-almost-finished-one-error-help-please/#findComment-1431980 Share on other sites More sharing options...
Solution luismc2007 Posted May 24, 2013 Author Solution Share Posted May 24, 2013 Hi. Yes, tonight I solve the problem... thanks. Now is other, but I´m going to investigate before post here. Thanks a lot for your help !!!! Quote Link to comment https://forums.phpfreaks.com/topic/278312-almost-finished-one-error-help-please/#findComment-1432009 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.