tracy Posted December 18, 2006 Author Share Posted December 18, 2006 by the way, I don't quite understand your first five or six lines of explanations in this code. I'm not sure I'm placing what I need to in those lines. I thought I'd have to reference the path there, not the thumbs file...could you explain a little about that? thanks for all your help. I can tell this file is working differently because of the way it is displaying...all red x's with hyperlink outline...but I'm sure that's because I haven't set up the files right...do I need to change the file folder names or the path in this code? Quote Link to comment https://forums.phpfreaks.com/topic/30792-uploading-photos-using-phpmysql/page/2/#findComment-143796 Share on other sites More sharing options...
craygo Posted December 18, 2006 Share Posted December 18, 2006 OK I changed a little to get rid of the red X's here is complete code[code]<?phpinclude('link.php');// Link to thumbnail images in reference to where this page is$thumb_path = "thumbs"; // this will be in a thumbs folder in the same directory as this file// Link to full size images in reference to where this page is$full_path = "."; // this would mean the full size images are in this same folder$query= mysql_query("SELECT * FROM inventory") or die("ERROR:" . mysql_error());$num = mysql_num_rows($query);if ($num == '0') {echo "Nothing Exist.";die();}else {?><table border="0" cellspacing="2" cellpadding="2"><tr><td><font face=Arial>Stock#</font></td><td><font face=Arial>Year</font></td><td><font face=Arial>Make</font></td><td><font face=Arial>Model</font></td><td><font face=Arial>Price</font></td><td><font face=Arial>Miles</font></td><td><font face=Arial>Photo1</font></td><td><font face=Arial>Photo2</font></td></tr><?phpwhile ($info = mysql_fetch_array($query)) {$stock = $info['stock'];$year = $info['year'];$make = $info['make'];$model = $info['model'];$price = $info['price'];$miles = $info['miles'];if($info['photo1'] == NULL){$photo1 = "[No image]";} else {$photo1 = "<a href=\"".$full_path."/".$info['photo1']."\"><img src=\"".$thumb_path."/".$info['photo1']."\"></a>";}if($info['photo2'] == NULL){$photo2 = "[No image]";} else {$photo2 = "<a href=\"".$full_path."/".$info['photo2']."\"><img src=\"".$thumb_path."/".$info['photo2']."\"></a>";}echo "<tr><td> <font face=Arial>".$stock."</font></td><td> <font face=Arial>".$year."</font></td><td> <font face=Arial>".$make."</font></td><td> <font face=Arial>".$model."</font></td><td> <font face=Arial>".$price."</font></td><td> <font face=Arial>".$miles."</font></td><td> <font face=Arial>".$photo1."</font></td><td> <font face=Arial>".$photo2."</font></td></tr>";}?></table><?php}?>[/code]OK what the first few lines does is tell your script where the thumbnail images are and the full size images are. I should of asked you this before but if you only want one image and that image be a certain size then let me know. The insert script will have to change and this one.So now when this line runs[code]if($info['photo1'] == NULL){$photo1 = "[No image]";} else {$photo1 = "<a href=\"".$full_path."/".$info['photo1']."\"><img src=\"".$thumb_path."/".$info['photo1']."\"></a>";}[/code]It will automatically find your thumbnail image and display it. And it will create a hyperlink to view the full size image. By putting those lines at the top, if you have images in a different folder you just have to change those line and not go through the entire script changing it.Ray Quote Link to comment https://forums.phpfreaks.com/topic/30792-uploading-photos-using-phpmysql/page/2/#findComment-143800 Share on other sites More sharing options...
tracy Posted December 18, 2006 Author Share Posted December 18, 2006 Thanks Ray. I appreciate it. Won't be able to try it until later but I look forward to it. Take it easy. Quote Link to comment https://forums.phpfreaks.com/topic/30792-uploading-photos-using-phpmysql/page/2/#findComment-143801 Share on other sites More sharing options...
tracy Posted December 19, 2006 Author Share Posted December 19, 2006 All right. I researched the $full_path at the php manual site. Could not find info that seems to apply in the first few lines of code...are you saying that by using "." after $full_path that it tells the php to use the same directory? The thumbs folder is in the same location as the images folder on the server. regarding the next to the last code I used, here are the errors...HOWEVER...it is loading all the data correctly except the photos...and shows error line 34 saying it can't write to the photo files (names them one at a time and then their thumbnail)...like it doesn't have permission.Then you sent the last code yesterday, I altered it some at the first few lines and it shows an error on line 22 and loads nothing into the database...here is my change: (the thumbs and images files are in the www folder which is the public folder for the server.<?phpinclude('link.php');// Link to thumbnail images in reference to where this page is$thumb_path = "thumbs"; // this will be in a thumbs folder in the same directory as this file// Link to full size images in reference to where this page is$full_path = "."; // this would mean the full size images are in this same folderTo answer your question, I'm trying to load these photos as 150x150 pixels (thumbnails) and link to the larger version. However, I also could simply upload 200x200 pixel thumbnails and forget about the big photo...with no link to it and not have it take up space on the server...I tried to research this myself but can't figure out why it won't load...hate to trouble you but I appreciate it.[quote author=craygo link=topic=118784.msg487521#msg487521 date=1166468831]OK I changed a little to get rid of the red X's here is complete code[code]<?phpinclude('link.php');// Link to thumbnail images in reference to where this page is$thumb_path = "thumbs"; // this will be in a thumbs folder in the same directory as this file// Link to full size images in reference to where this page is$full_path = "."; // this would mean the full size images are in this same folder$query= mysql_query("SELECT * FROM inventory") or die("ERROR:" . mysql_error());$num = mysql_num_rows($query);if ($num == '0') {echo "Nothing Exist.";die();}else {?><table border="0" cellspacing="2" cellpadding="2"><tr><td><font face=Arial>Stock#</font></td><td><font face=Arial>Year</font></td><td><font face=Arial>Make</font></td><td><font face=Arial>Model</font></td><td><font face=Arial>Price</font></td><td><font face=Arial>Miles</font></td><td><font face=Arial>Photo1</font></td><td><font face=Arial>Photo2</font></td></tr><?phpwhile ($info = mysql_fetch_array($query)) {$stock = $info['stock'];$year = $info['year'];$make = $info['make'];$model = $info['model'];$price = $info['price'];$miles = $info['miles'];if($info['photo1'] == NULL){$photo1 = "[No image]";} else {$photo1 = "<a href=\"".$full_path."/".$info['photo1']."\"><img src=\"".$thumb_path."/".$info['photo1']."\"></a>";}if($info['photo2'] == NULL){$photo2 = "[No image]";} else {$photo2 = "<a href=\"".$full_path."/".$info['photo2']."\"><img src=\"".$thumb_path."/".$info['photo2']."\"></a>";}echo "<tr><td> <font face=Arial>".$stock."</font></td><td> <font face=Arial>".$year."</font></td><td> <font face=Arial>".$make."</font></td><td> <font face=Arial>".$model."</font></td><td> <font face=Arial>".$price."</font></td><td> <font face=Arial>".$miles."</font></td><td> <font face=Arial>".$photo1."</font></td><td> <font face=Arial>".$photo2."</font></td></tr>";}?></table><?php}?>[/code]OK what the first few lines does is tell your script where the thumbnail images are and the full size images are. I should of asked you this before but if you only want one image and that image be a certain size then let me know. The insert script will have to change and this one.So now when this line runs[code]if($info['photo1'] == NULL){$photo1 = "[No image]";} else {$photo1 = "<a href=\"".$full_path."/".$info['photo1']."\"><img src=\"".$thumb_path."/".$info['photo1']."\"></a>";}[/code]It will automatically find your thumbnail image and display it. And it will create a hyperlink to view the full size image. By putting those lines at the top, if you have images in a different folder you just have to change those line and not go through the entire script changing it.Ray[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/30792-uploading-photos-using-phpmysql/page/2/#findComment-144496 Share on other sites More sharing options...
craygo Posted December 19, 2006 Share Posted December 19, 2006 ok give me your directory structure and I will fix itexamplethe php file location/home/mydomain/public_htmlthumbnails folder/home/mydomain/public_html/images/thumbsfull size images/home/mydomain/public_html/imagesnow since the php file is in the web root, in order to access the files, you would have to use this$thumbs_path = "images/thumbs";$full_path = "images";All file paths and links are always in reference to where the script is running from.Also yes if the images are in the same folder as the php file then you would use "."If it is a linux box make the images folder chmod 777. And you need to make it recursive in order to make sure all folders under the images folder get the permissions also. If not go to each folder seperately.Ray Quote Link to comment https://forums.phpfreaks.com/topic/30792-uploading-photos-using-phpmysql/page/2/#findComment-144525 Share on other sites More sharing options...
tracy Posted December 19, 2006 Author Share Posted December 19, 2006 Sometimes in the past when I set the security to 777 it won't work at all...none of the php pages, but I'll try it. Someone said that is a security issue...what do you think about it?My structure is this:the main public folder that browsers surf to is public_html the images folder is public_html/imagesthe thumbs folder is public_html/imagesBy the way, so you won't think I'm lazy, I changed a lot of that in the code yesterday but it didn't work. I'm certain it was probably my error, though...syntax or something. Still learning this php...thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/30792-uploading-photos-using-phpmysql/page/2/#findComment-144526 Share on other sites More sharing options...
craygo Posted December 19, 2006 Share Posted December 19, 2006 ok i think your error may be a combination of a couple thing. The way the script is written the thumbs and the images shouldn't be in the same folder. Because the images and the thumbs are the same name you will get an error because it will try to overwrite one of them. Second some hosting companies do have limits on the file permission. try 775 on the folders.Make a thumbs folder in your images folder and use my example in my last post and it should work. If not post your current code.Ray Quote Link to comment https://forums.phpfreaks.com/topic/30792-uploading-photos-using-phpmysql/page/2/#findComment-144531 Share on other sites More sharing options...
tracy Posted December 19, 2006 Author Share Posted December 19, 2006 what directory should I use? the html_public is the public directory...should I create a new folder in there and call it whatever and put the thumbs folder in it? And what about security if I change the values on these to 775 or 777? Thanks.[quote author=craygo link=topic=118784.msg488259#msg488259 date=1166543480]ok i think your error may be a combination of a couple thing. The way the script is written the thumbs and the images shouldn't be in the same folder. Because the images and the thumbs are the same name you will get an error because it will try to overwrite one of them. Second some hosting companies do have limits on the file permission. try 775 on the folders.Make a thumbs folder in your images folder and use my example in my last post and it should work. If not post your current code.Ray [/quote] Quote Link to comment https://forums.phpfreaks.com/topic/30792-uploading-photos-using-phpmysql/page/2/#findComment-144532 Share on other sites More sharing options...
tracy Posted December 19, 2006 Author Share Posted December 19, 2006 I tried the 777 and the 775 and I moved the folder for thumbs to the etc folder which is the same level as the www folder but an altogether folder. No go...error line 34...same issue apparently. Now I'm locked out of all those files for some reason...like a security thing. Emailed my host...Changed the permissions from 777 to 666 to 775 and now back to 777...no access. Thoughts? Thanks.[quote author=craygo link=topic=118784.msg488259#msg488259 date=1166543480]ok i think your error may be a combination of a couple thing. The way the script is written the thumbs and the images shouldn't be in the same folder. Because the images and the thumbs are the same name you will get an error because it will try to overwrite one of them. Second some hosting companies do have limits on the file permission. try 775 on the folders.Make a thumbs folder in your images folder and use my example in my last post and it should work. If not post your current code.Ray [/quote] Quote Link to comment https://forums.phpfreaks.com/topic/30792-uploading-photos-using-phpmysql/page/2/#findComment-144699 Share on other sites More sharing options...
craygo Posted December 19, 2006 Share Posted December 19, 2006 what hosting company are you using. You shouldn't use any folders below the public_html folder. Any folders on the same level as that are not accessible through ftp or web browsing. I tested your script on my server which is hosted by ephaze and when I changed my folder permissions to 777 they were fine. my structure is:/home/user/public_html/misc/images/thumbsthe full size pics are in the images folder and the thumbs are in the thumbs folder. I used my ftp client to set the images folder permissions to 777 and then it asked me if I wanted to set the same for all files and folders and I said yes. Everything was fine after that.If it is a permission problem contact the web hosting company and see what you can do. If they have restrictions not much anyone can do about that.Ray Quote Link to comment https://forums.phpfreaks.com/topic/30792-uploading-photos-using-phpmysql/page/2/#findComment-144720 Share on other sites More sharing options...
tracy Posted December 19, 2006 Author Share Posted December 19, 2006 Yeah, I already contacted them...I appreciate it. Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/30792-uploading-photos-using-phpmysql/page/2/#findComment-144722 Share on other sites More sharing options...
simcoweb Posted December 19, 2006 Share Posted December 19, 2006 Create the folder like craygo pointed out:/home/user/public_html/misc/images/thumbsYour path may be different so plug in the necessary replacements. Then, set the folder permissions to 777. BUT, be SURE to put an 'index.htm' file in that folder . This prevents snoopers from simply typing in your images/thumbs url and displaying all your pics. The index.htm file will show up by default. It can be as simple as one line of text saying 'You shouldn't be here'. Quote Link to comment https://forums.phpfreaks.com/topic/30792-uploading-photos-using-phpmysql/page/2/#findComment-144724 Share on other sites More sharing options...
tracy Posted December 19, 2006 Author Share Posted December 19, 2006 Thank you both. Working on it...having to rebuild some stuff... Quote Link to comment https://forums.phpfreaks.com/topic/30792-uploading-photos-using-phpmysql/page/2/#findComment-144751 Share on other sites More sharing options...
tracy Posted December 19, 2006 Author Share Posted December 19, 2006 here's the new situation with this code...I rebuilt another website with three files: the connection file, the display file and the load file, shown below. The display works fine except that the picture is only the name of the picture. That says the connection is good and the code generally is working. The errors below tell me there is a security issue with permissions most likely.However, I built this new WEBSITE just to test this. I had the files at standard settings and got the errors below. I changed the images and the thumbs file to 777 and still nothing...same error. I changed the file itself, the load file (the php code below) to permission 777 since the error says it can't write to itself...now I can't access the page at all again...Should we not use a self posting form or would this make a difference? Thanks.Warning: imagejpeg() [function.imagejpeg]: Unable to open '/public_html/images//ephotos 3 004.jpg' for writing in /home/working/public_html/imageUPLOAD.php on line 34Warning: imagejpeg() [function.imagejpeg]: Unable to open '/public_html/images/thumbs//ephotos 3 004.jpg' for writing in /home/working/public_html/imageUPLOAD.php on line 34it's like I can't write to the photo file itself...here is the php...<?php$absolute_path = "/public_html/images/"; //Absolute path to where files are uploaded$thumb_path = "/public_html/images/thumbs/"; //Absolute path to where thumbs are to be stored if you want this$size_limit = "yes"; //do you want a size limit yes or no.$limit_size = "600000"; //How big do you want size limit to be in bytes$limit_ext = "yes"; //do you want to limit the extensions of files uploaded$ext_count = "1"; //total number of extensions in array below$extensions = array(".jpg"); //List extensions you want files uploaded to befunction resampimagejpg($forcedwidth, $forcedheight, $sourcefile, $destfile, $imgcomp) { $g_imgcomp=100-$imgcomp; $g_srcfile=$sourcefile; $g_dstfile=$destfile; $g_fw=$forcedwidth; $g_fh=$forcedheight; if(file_exists($g_srcfile)) { $g_is=getimagesize($g_srcfile); if(($g_is[0]-$g_fw)>=($g_is[1]-$g_fh)) { $g_iw=$g_fw; $g_ih=($g_fw/$g_is[0])*$g_is[1]; } else { $g_ih=$g_fh; $g_iw=($g_ih/$g_is[1])*$g_is[0]; } $img_src=imagecreatefromjpeg($g_srcfile); $img_dst=imagecreatetruecolor($g_iw,$g_ih); imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $g_iw, $g_ih, $g_is[0], $g_is[1]); imagejpeg($img_dst, $g_dstfile, $g_imgcomp); imagedestroy($img_dst); return true; } else return false; }if(!isset($_POST['submit'])){ if (($extensions == "") or ($extensions == " ") or ($ext_count == "0") or ($ext_count == "") or ($limit_ext != "yes") or ($limit_ext == "")) { $extens = "any extension"; } else { $ext_count2 = $ext_count+1; for($counter=0; $counter<$ext_count; $counter++) { $extens = " $extensions[$counter]"; } } if (($limit_size == "") or ($size_limit != "yes")) { $limit_size = "any size"; } else { $limit_size .= " bytes"; $mb_size = ($limit_size/1000000); } $pichead = "<li><font size=\"2\" color=660000>File extension must be $extens<b>"; $pichead .="</b></font> <li><font size=\"2\" color=660000>Maximum file size is $limit_size ($mb_size MB)</font></li> <li><font size=\"2\" color=660000>No spaces in the filename</font></li>";?><html><head><title>HTML Form for uploading image to server</title></head><body><form action="" method="post" enctype="multipart/form-data"><html><title>Add Vehicle Form</title><body><form action="<?=$_SERVER['PHP_SELF']?>" method="post"><table width=400 align=center><tr><td>Stock Number:</td><td><input type="text" name="stock" /></td></tr><td>Year:</td><td><input type="text" name="year" /></td></tr><td>Make:</td><td><input type="text" name="make" /></td></tr><td>Model:</td><td><input type="text" name="model" /></td></tr><td>Price:</td><td><input type="text" name="price" /></td></tr><td>Miles:</td><td><input type="text" name="miles" /></td></tr><tr><td colspan=2 align=center><?=$pichead?><p>Pictures:<br />1 <input type="file" name="pictures[]" /><br />2 <input type="file" name="pictures[]" /><br />3 <input type="file" name="pictures[]" /><br />4 <input type="file" name="pictures[]" /><br />5 <input type="file" name="pictures[]" /><br />6 <input type="file" name="pictures[]" /><br /><input type="submit" name=submit value="Send" /></p></form></body></html><?php} else {$i=0;$photoarray = array(); foreach ($_FILES["pictures"]["error"] as $key => $error) { $file_name = $_FILES["pictures"]['name'][$i]; // can call this anything you like this will take the original name $file = $_FILES["pictures"]['tmp_name'][$i]; $photoarray[$i+1]= $file_name; $endresult = "<font size=\"4\" color=990000>$file_name uploaded successfully</font>"; if ($file_name == "") { $pic = $i+1; $endresult = "<font size=\"4\" color=990000>Pic#$pic Not selected</font>"; }else{ if(file_exists("$absolute_path/$file_name")) { $endresult = "<font size=\"4\" color=990000>File Already Existed</font>"; } else { if (($size_limit == "yes") && ($limit_size < $file_size)) { $endresult = "<font size=\"4\" color=990000>File was to big</font>"; } else { $ext = strrchr($file_name,'.'); if (($limit_ext == "yes") && (!in_array($ext,$extensions))) { $endresult = "<font size=\"4\" color=990000>File is wrong type</font>"; }else{ // Save full size image with max width/height resampimagejpg(1000,1000,$file,"$absolute_path/$file_name",0); // Save thumb image with max width/height of 200 resampimagejpg(200,200,$file,"$thumb_path/$file_name",0); //copy($file, "$absolute_path/$file_name") or $endresult = "<font size=\"4\" color=990000>Couldn't Copy File To Server</font>"; } } } } $i++; echo $endresult."<br>"; }/********* Connection to mysql below **********/include "link.php";/*********** End connection string ************/$sql = "INSERT INTO inventory SET stock = '".$_POST['stock']."', year = '".$_POST['year']."', make = '".$_POST['make']."', model = '".$_POST['model']."', miles = '".$_POST['miles']."', price = '".$_POST['price']."', photo1 = '".$photoarray[1]."', photo2 = '".$photoarray[2]."', photo3 = '".$photoarray[3]."', photo4 = '".$photoarray[4]."', photo5 = '".$photoarray[5]."', photo6 = '".$photoarray[6]."'";$res = mysql_query($sql);if(!$res){echo "Could not insert Row<br>Error: ".mysql_error()."<br>SQL: ".$sql;} else {echo "Row inserted";}}?></body></html> Quote Link to comment https://forums.phpfreaks.com/topic/30792-uploading-photos-using-phpmysql/page/2/#findComment-144762 Share on other sites More sharing options...
tracy Posted December 19, 2006 Author Share Posted December 19, 2006 I am getting errors Warning: imagejpeg() [function.imagejpeg]: Unable to open '/public_html/images//Auto Alt 6-9-06 005.jpg' for writing in /home/working/public_html/imageUPLOAD.php on line 34Warning: imagejpeg() [function.imagejpeg]: Unable to open '/public_html/images/thumbs//Auto Alt 6-9-06 005.jpg' for writing in /home/working/public_html/imageUPLOAD.php on line 34I changed the permissions several times to various levels, including 777...no success.It is writing to the database table, not fixing the picture problem. Any ideas? Thanks for all your help...[quote author=craygo link=topic=118784.msg488253#msg488253 date=1166542773]ok give me your directory structure and I will fix itexamplethe php file location/home/mydomain/public_htmlthumbnails folder/home/mydomain/public_html/images/thumbsfull size images/home/mydomain/public_html/imagesnow since the php file is in the web root, in order to access the files, you would have to use this$thumbs_path = "images/thumbs";$full_path = "images";All file paths and links are always in reference to where the script is running from.Also yes if the images are in the same folder as the php file then you would use "."If it is a linux box make the images folder chmod 777. And you need to make it recursive in order to make sure all folders under the images folder get the permissions also. If not go to each folder seperately.Ray[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/30792-uploading-photos-using-phpmysql/page/2/#findComment-144781 Share on other sites More sharing options...
craygo Posted December 19, 2006 Share Posted December 19, 2006 problem is your putting a "/" at the end of the paths. they should be[code]$absolute_path = "/public_html/images"; //Absolute path to where files are uploaded$thumb_path = "/public_html/images/thumbs"; //Absolute path to where thumbs are to be stored if you want this[code]Actually you need to put the actual path which is from the root[code]$absolute_path = "/home/username/public_html/images"; //Absolute path to where files are uploaded$thumb_path = "/home/username/public_html/images/thumbs"; //Absolute path to where thumbs are to be stored if you want this[/code]Ray[/code][/code] Quote Link to comment https://forums.phpfreaks.com/topic/30792-uploading-photos-using-phpmysql/page/2/#findComment-144785 Share on other sites More sharing options...
tracy Posted December 20, 2006 Author Share Posted December 20, 2006 I've (yesterday) tried it with and without the slashes...here is the error when I use simply "public_html/images" and "public_html/images/thumbs"...Warning: imagejpeg() [function.imagejpeg]: Unable to open 'public_html/images/ephotos 3 002.jpg' for writing in /home/working/public_html/imageUPLOAD.php on line 34Warning: imagejpeg() [function.imagejpeg]: Unable to open 'public_html/images/thumbs/ephotos 3 002.jpg' for writing in /home/working/public_html/imageUPLOAD.php on line 34ephotos 3 002.jpg uploaded successfullyI only tried to upload one file. The data went into database with photo name, only this error shows and photo isn't showing in db, obviously...It says it can't open the actual image, as the image name is ephotos 3 002.jpg that I tried to send...I can't see the image loaded in the file, either, on the server so I know it didn't go...Any further advice is appreciated. You stated that you tried it on your site and it works...can you tell me if I should substitute the word home or user or something for my domain name...even though I tried all that, I could have missed one combination that might work. Thanks...[quote author=craygo link=topic=118784.msg488516#msg488516 date=1166568389]problem is your putting a "/" at the end of the paths. they should be[code]$absolute_path = "/public_html/images"; //Absolute path to where files are uploaded$thumb_path = "/public_html/images/thumbs"; //Absolute path to where thumbs are to be stored if you want this[code]Actually you need to put the actual path which is from the root[code]$absolute_path = "/home/username/public_html/images"; //Absolute path to where files are uploaded$thumb_path = "/home/username/public_html/images/thumbs"; //Absolute path to where thumbs are to be stored if you want this[/code]Ray[/code][/code][/quote] Quote Link to comment https://forums.phpfreaks.com/topic/30792-uploading-photos-using-phpmysql/page/2/#findComment-145150 Share on other sites More sharing options...
tracy Posted December 20, 2006 Author Share Posted December 20, 2006 Thanks for index file info...did that...[quote author=simcoweb link=topic=118784.msg488453#msg488453 date=1166559319]Create the folder like craygo pointed out:/home/user/public_html/misc/images/thumbsYour path may be different so plug in the necessary replacements. Then, set the folder permissions to 777. BUT, be SURE to put an 'index.htm' file in that folder . This prevents snoopers from simply typing in your images/thumbs url and displaying all your pics. The index.htm file will show up by default. It can be as simple as one line of text saying 'You shouldn't be here'.[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/30792-uploading-photos-using-phpmysql/page/2/#findComment-145151 Share on other sites More sharing options...
tracy Posted December 20, 2006 Author Share Posted December 20, 2006 why do I see home and user in your path? Can you explain more? Thanks.My www is the file folder that holds the php page...it is a clone of the public_html file...then inside that is the image file and inside that the thumbs file. Thanks.[quote author=simcoweb link=topic=118784.msg488453#msg488453 date=1166559319]Create the folder like craygo pointed out:/home/user/public_html/misc/images/thumbsYour path may be different so plug in the necessary replacements. Then, set the folder permissions to 777. BUT, be SURE to put an 'index.htm' file in that folder . This prevents snoopers from simply typing in your images/thumbs url and displaying all your pics. The index.htm file will show up by default. It can be as simple as one line of text saying 'You shouldn't be here'.[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/30792-uploading-photos-using-phpmysql/page/2/#findComment-145224 Share on other sites More sharing options...
tracy Posted December 20, 2006 Author Share Posted December 20, 2006 I have solved the paths issue. I think. Files, including photos, no longer generate errors on upload. However, they only display red x in table when viewed via the display page in php...here is the code for that page...I am only displaying one photo for now, just to test...<?phpinclude('link.php');// Link to thumbnail images in reference to where this page is$thumb_path = "/home/working/public_html/images/thumbs"; // this will be in a thumbs folder in the same directory as this file// Link to full size images in reference to where this page is$full_path = "."; // this would mean the full size images are in this same folder$query= mysql_query("SELECT * FROM inventory") or die("ERROR:" . mysql_error());$num = mysql_num_rows($query);if ($num == '0') {echo "Nothing Exist.";die();}else {?><table border="0" cellspacing="2" cellpadding="2"><tr><td><font face=Arial>Stock#</font></td><td><font face=Arial>Year</font></td><td><font face=Arial>Make</font></td><td><font face=Arial>Model</font></td><td><font face=Arial>Price</font></td><td><font face=Arial>Miles</font></td><td><font face=Arial>Photo1</font></td><td><font face=Arial>Photo2</font></td></tr><?phpwhile ($info = mysql_fetch_array($query)) {$stock = $info['stock'];$year = $info['year'];$make = $info['make'];$model = $info['model'];$price = $info['price'];$miles = $info['miles'];if($info['photo1'] == NULL){$photo1 = "[No image]";} else {$photo1 = "<a href=\"".$full_path."/".$info['photo1']."\"><img src=\"".$thumb_path."/".$info['photo1']."\"></a>";}if($info['photo2'] == NULL){$photo2 = "[No image]";} else {$photo2 = "<a href=\"".$full_path."/".$info['photo2']."\"><img src=\"".$thumb_path."/".$info['photo2']."\"></a>";}echo "<tr><td> <font face=Arial>".$stock."</font></td><td> <font face=Arial>".$year."</font></td><td> <font face=Arial>".$make."</font></td><td> <font face=Arial>".$model."</font></td><td> <font face=Arial>".$price."</font></td><td> <font face=Arial>".$miles."</font></td><td> <font face=Arial>".$photo1."</font></td><td> <font face=Arial>".$photo2."</font></td></tr>";}?></table><?php}?> Quote Link to comment https://forums.phpfreaks.com/topic/30792-uploading-photos-using-phpmysql/page/2/#findComment-145252 Share on other sites More sharing options...
craygo Posted December 20, 2006 Share Posted December 20, 2006 OK i hope this does not mess you up so I will try to explain things a little better.When working with files and uploads and things or that nature, it is best practice to use the absolute path to the folder you are working with. So even though you do not see the /home/working it is there. the hosting company just doesn't allow you to see those folders. But the web server sees everything so you need to include it with your script.Now on the other hand when you want to show the pictures you have uploaded you have to show the path reletive to the folder the script is running in. So your paths on the page that shows the folders should be[code]// Link to thumbnail images in reference to where this page is$thumb_path = "thumbs"; // this will be in a thumbs folder in the same directory as this file// Link to full size images in reference to where this page is$full_path = "."; // this would mean the full size images are in this same folder[/code]I hope that helps a littleRay Quote Link to comment https://forums.phpfreaks.com/topic/30792-uploading-photos-using-phpmysql/page/2/#findComment-145272 Share on other sites More sharing options...
tracy Posted December 20, 2006 Author Share Posted December 20, 2006 So, based on what you are saying, what should the code be at the path section...because none I have tried shows the photos/thumbnails...only red x's...I have tried:thumbs/thumbsimages/thumbspublic_html/images/thumbshome/working/public_html/images/thumbsWhat am I missing here?I even tried to change the path in the actual mysql database to add the path directly there...no success. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/30792-uploading-photos-using-phpmysql/page/2/#findComment-145297 Share on other sites More sharing options...
php001 Posted December 20, 2006 Share Posted December 20, 2006 [quote author=complex05 link=topic=118784.msg485670#msg485670 date=1166214222]If you really do what to put the images directly into the database, here is a good tutorial on how to do it.http://www.phpfreaks.com/tutorials/85/0.phpHope that helps![/quote]Thanks. really Good tutorial . Quote Link to comment https://forums.phpfreaks.com/topic/30792-uploading-photos-using-phpmysql/page/2/#findComment-145323 Share on other sites More sharing options...
tracy Posted December 20, 2006 Author Share Posted December 20, 2006 Thank you but I don't want them in the database, just a reference to them via a thumbnail. New user? Welcome to phpfreaks.com...[quote author=php001 link=topic=118784.msg489062#msg489062 date=1166637038][quote author=complex05 link=topic=118784.msg485670#msg485670 date=1166214222]If you really do what to put the images directly into the database, here is a good tutorial on how to do it.http://www.phpfreaks.com/tutorials/85/0.phpHope that helps![/quote]Thanks. really Good tutorial .[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/30792-uploading-photos-using-phpmysql/page/2/#findComment-145326 Share on other sites More sharing options...
craygo Posted December 20, 2006 Share Posted December 20, 2006 Is this site public?? can you give me a link to it. I want to view what is being outputted to the browser. I recreated your pages on my web site. This is the page which shows the resultshttp://www.theelders.net/misc/show.phpand this is the page that uploads the fileshttp://www.theelders.net/misc/stockmanage.phpSo with that here are the paths at the top of show.php. Which returns the database results and the pics. The full size images are in the same place as the show.php file and the thimbs are in a folder called thumbs that is in the misc folder.[code]// Link to thumbnail images in reference to where this page is$thumb_path = "thumbs"; // this will be in a thumbs folder in the same directory as this file// Link to full size images in reference to where this page is$full_path = "."; // this would mean the full size images are in this same folder[/code]Now here is the links for the insert and file upload page. which is stockmanage.php[code]$absolute_path = "/home/username/public_html/misc"; //Absolute path to where files are uploaded$thumb_path = "/home/username/public_html/misc/thumbs"; //Absolute path to where thumbs are to be stored if you want this[/code]Ray Quote Link to comment https://forums.phpfreaks.com/topic/30792-uploading-photos-using-phpmysql/page/2/#findComment-145342 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.