sturbitt Posted February 20, 2007 Share Posted February 20, 2007 I am trying to save my thumbnails but I need to save them with the size that they are in the path of the directory or in the file name, however everytime I insert the interger into the string my script stops working. I have tried to convert the int to string with strval() but it didnt work either. Here is one of the attempts I have made: $trgdir = "_thumbs\\$directory"; if(!(file_exists("$trgdir"))) { mkdir("$trgdir"); } $sizeandfile = strval($thumbsize); $sizeandfile = "$sizeandfile$image"; $trgfile = "$trgdir\\$image"; if(!(file_exists("$trgfile"))) { imagejpeg($thumb, $trgfile); } I have tried loads of thing like concating strings and thing but to no avail. Cheers Steven Quote Link to comment Share on other sites More sharing options...
skali Posted February 21, 2007 Share Posted February 21, 2007 $sizeandfile = $thumbsize; $sizeandfile = $sizeandfile.$image; Quote Link to comment Share on other sites More sharing options...
sturbitt Posted February 21, 2007 Author Share Posted February 21, 2007 Thanks for the suggestion but its still not working. My main problem is I don't get error message as the script is dealling with images and all I get is no picture displayed. I am going to try and build another script with just making directories bit in it and see if I can get an error message. Any other suggestions in the mean time? Thanks again for your help. Quote Link to comment Share on other sites More sharing options...
compas Posted February 21, 2007 Share Posted February 21, 2007 Hi, Is $thumb is the resource object which is the result of imagecreate function? Do you want to upload a thumbnail to the application using file upload and store it in the server? Thanks Compas Quote Link to comment Share on other sites More sharing options...
redarrow Posted February 21, 2007 Share Posted February 21, 2007 the easy way mate now all you do is the database connection then echo pic via html img src ok. 1. make folder new_upload. 2. call the script upload.php test it without the database first ok. <?php // database connection. //$db=mysql_connect("locahost","username","password"); //mysql_select_db("database_name",$db); //random number $num="123456"; $num=rand(000000,111111); // directory path. $uploaddir = 'upload_new/'; // get the dir to send file to and the file name. $uploadfile = $uploaddir . basename($_FILES['userfile']['name']); $file=$uploadfile; $ext = substr($file, -4); $uploadfile=$uploaddir.$num.$ext; @rename($file,$uplaodfile); // if all the conditions are correct send the file to the directory. if(move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)){ //database protection. //$num=addslashes($_POST['num']); //query insert. //$query="insert into colmn_name ('uplaodfile')values('uploadfile)"; //$result2=mysql_query($query); // success echoed echo " <font color='red'>File is valid, and was successfully uploaded.</font>"; }else { //unsuccesfull echoed echo "<font color='red'>File was unsuccesful sorry</font>"; } // show the form. echo" <form enctype='multipart/form-data' action='upload.php' method='POST'> <input type='hidden' name='MAX_FILE_SIZE' value='30000000000000000000000'> send this file <input name='userfile' type='file' > <input type='submit' name='submit' value='Send File'> </form>"; ?> Quote Link to comment Share on other sites More sharing options...
sturbitt Posted February 21, 2007 Author Share Posted February 21, 2007 Thanks for the help! I was looking at possibly using the database some how but I am not very good with DBs (not my thing). The $image is the thumb nail I have already generated the picture. All I am tring to do is save that file to disk so that the next time I need it I don't need to regenerate the picture (hopefully speeding up my web site). So My plan was to create a "_thumbs" directory in the root of the web site and save all my thumbnails into that in the same directory structure as the rest of the web site (to avoid duplication). I can do this, but I also offer the ability to view the picture in different sizes (small medium and large) for this I just reuse the thumbnail generation scripts but do it bigger. So what I would like to do is put the size of the image stored in the file name or directory structure: i.e: _thumbs\150\testdir\test.jpg or _thumbs\testdir\150test.jpg But every time I mention the $imagesize variable anywhere the whole thing stops working - it works fine without it! I will try and digest the DB solution with the upload script but its getting frustrating as to why my script isn't working. Thanks again! Quote Link to comment 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.