johntp Posted October 27, 2006 Share Posted October 27, 2006 getting this error:Warning: copy(Uploadimages/): failed to open stream: Is a directory in /mounted-storage/home23b/sub003/sc21754-QIFR/www/mainscript/uploadphoto.php on line 7and here is the code:[sup]<? session_start();require_once("include/config.php");$new_width=100; //Image width Change if needed$new_height=100; $userId=$_SESSION['user_id'];copy ($pingvin, "Uploadimages/$pingvin_new"); $add1="Uploadimages/$pingvin_new"; $thumbnailpath1="thumnailimages/$pingvin_new"; $query="insert into myspaceuserpicture (UserID,UseImagepath,Userthubnailpath,imagetype) values ('$userId','$add1','$thumbnailpath1','1')"; mysql_query($query) or handle_mysql_error($query,mysql_errno(),mysql_error); $id = mysql_insert_id($cn); $uploaddone="sucess"; if($uploaddone=="sucess") { header("location:step2.php"); } else { header("location:step1.php?error=ix"); }?>[/sup]Now Uploadimages is a folder where i want the pic to get copied in any ideas ?????? Quote Link to comment Share on other sites More sharing options...
gmwebs Posted October 27, 2006 Share Posted October 27, 2006 Well the error means something is missing. What is the value of $pingvin_new? Quote Link to comment Share on other sites More sharing options...
johntp Posted October 29, 2006 Author Share Posted October 29, 2006 hmmmm. there is no value for $pingvin_new what should i set as the value if it needs to be the picture that was uploaded Quote Link to comment Share on other sites More sharing options...
johntp Posted October 30, 2006 Author Share Posted October 30, 2006 well i was wrong in the page beforeit it calls for it.[sup]<? session_start();require_once("include/config.php");if(!isset($_SESSION['user_id'])){ header("location:login.php");}$lastlogin=$_SESSION['lastlogin'];$userId=$_SESSION['user_id']; ?> <html><head> <title>Fijispace.com</title> <meta name="keywords" content="friends networking sharing photos finding friends blogs journals blogging journaling bands music rate pics join groups forums classifieds online social networking"> <meta name="description" content="Find old friends and meet new friends as you network, share photos, create blogs, and more at Websitename"> <meta http-equiv="expires" content="0"><meta http-equiv="Pragma" content="no-cache"><link rel="STYLESHEET" type="text/css" href="stylesheet/stylesheet.css"></head><body bgcolor="e5e5e5" alink="4e607b" link="4e607b" vlink="4e607b" bottommargin="0" leftmargin="0" rightmargin="0" topmargin="0" onLoad=""> <? require_once("headeraddprfile.php"); ?><div align="center"><table bgcolor="ffffff" bordercolor="ffffff" cellpadding="5" cellspacing="5" border="0" width="800"> <tr> <td><span class="blacktext15">Upload Some Photos!</span></td> </tr> <tr> <td valign="top"> <form method="post" action="uploadphoto.php" enctype="multipart/form-data"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td colspan="3"><span class="blacktext13">Share your photos to let friends and other members see who you are</span></td> </tr><tr> </tr><tr> <td colspan="3"> <span class="text"> Photos may be a max of 600K in these formats: JPG <br>Photos may not contain nudity, violent or offensive material, or copyrighted images. </span> </td> </tr> </table> <br> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr valign="top"> <td width="325"> <br> <TABLE class="blue_border" id="Table2" style="BORDER-COLLAPSE: collapse" cellSpacing="0" cellPadding="2" width="60%" border="0"> <TR> <TD class="blue_header" colSpan="2" height="10">Upload Photo</TD> </tr> <TR> <tr> <td Colspan="2"> [color=red] <input type="file" name="pingvin">[/color] </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td Colspan="2" align="right"> <input type="submit" class="submit_button" name="submit" value="Upload"> </td> </tr> </table> <BR> <BR> <a href="step2.php?skip=checkone">Skip for now</a> </td> <td> <div align="center"><img src="images/profile_w_photo_03.bmp" width="344" height="460"></div> </td> </tr> </table> <p><br> </p> </form> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr></table> <? require_once("footer.php"); ?> </body> </html> [/sup] Quote Link to comment Share on other sites More sharing options...
gmwebs Posted October 30, 2006 Share Posted October 30, 2006 Ok, so change your first bit of code that you included in your first post to this...[code]<?php session_start();require_once("include/config.php");$new_width=100; //Image width Change if needed$new_height=100; $userId=$_SESSION['user_id'];echo $pingvin; //Echo the value of the variableexit(); //Exit the script so you can see the outputcopy ($pingvin, "Uploadimages/$pingvin_new"); $add1="Uploadimages/$pingvin_new"; $thumbnailpath1="thumnailimages/$pingvin_new"; $query="insert into myspaceuserpicture (UserID,UseImagepath,Userthubnailpath,imagetype) values ('$userId','$add1','$thumbnailpath1','1')"; mysql_query($query) or handle_mysql_error($query,mysql_errno(),mysql_error); $id = mysql_insert_id($cn); $uploaddone="sucess"; if($uploaddone=="sucess") { header("location:step2.php"); } else { header("location:step1.php?error=ix"); }?>[/code]What we are trying to do is ascertain what is missing in the script. So in order to do so, you need to troubleshoot the execution of the code step-by-step. Quote Link to comment Share on other sites More sharing options...
johntp Posted October 30, 2006 Author Share Posted October 30, 2006 well now after i hit upload i get this /tmp/phpbjhWbA Quote Link to comment Share on other sites More sharing options...
gmwebs Posted October 30, 2006 Share Posted October 30, 2006 Ok... So that looks like a temporary filename, which is good... Now try this...[code]<?php session_start();require_once("include/config.php");$new_width=100; //Image width Change if needed$new_height=100; $userId=$_SESSION['user_id'];echo $pingvin_new; //Echo the value of the variable - lets see if there is a filename to copy TOexit(); //Exit the script so you can see the outputcopy ($pingvin, "Uploadimages/$pingvin_new"); $add1="Uploadimages/$pingvin_new"; $thumbnailpath1="thumnailimages/$pingvin_new"; $query="insert into myspaceuserpicture (UserID,UseImagepath,Userthubnailpath,imagetype) values ('$userId','$add1','$thumbnailpath1','1')"; mysql_query($query) or handle_mysql_error($query,mysql_errno(),mysql_error); $id = mysql_insert_id($cn); $uploaddone="sucess"; if($uploaddone=="sucess") { header("location:step2.php"); } else { header("location:step1.php?error=ix"); }?>[/code] Quote Link to comment Share on other sites More sharing options...
johntp Posted October 30, 2006 Author Share Posted October 30, 2006 now it's just a blank page, but the pic isn't in the directories Quote Link to comment Share on other sites More sharing options...
gmwebs Posted October 30, 2006 Share Posted October 30, 2006 Ok... So that means that the $pingvin_new variable is empty. So that proves that the error message is right :)Obviously, you are supposed to assign a filename to that variable, which is not happening. Is that all the code in the uploadphoto.php file? Quote Link to comment Share on other sites More sharing options...
johntp Posted October 30, 2006 Author Share Posted October 30, 2006 yep, that is all the code in uploadphoto.php and step1.php. there is uploadphoto.php and step1.php that you select the file then it calls for uploadphoto.php. Quote Link to comment Share on other sites More sharing options...
gmwebs Posted October 30, 2006 Share Posted October 30, 2006 Ok, try to assign a variable manually then, just to see if it creates your file. You would need to manually assign the extension for now, but we can have a look at getting that done automatically later on.[code]<?php session_start();require_once("include/config.php");$new_width=100; //Image width Change if needed$new_height=100; $userId=$_SESSION['user_id'];$pingvin_new = "testfile.jpg"; //make the extension the same as you are uploading for nowcopy ($pingvin, "Uploadimages/$pingvin_new"); $add1="Uploadimages/$pingvin_new"; $thumbnailpath1="thumnailimages/$pingvin_new"; $query="insert into myspaceuserpicture (UserID,UseImagepath,Userthubnailpath,imagetype) values ('$userId','$add1','$thumbnailpath1','1')"; mysql_query($query) or handle_mysql_error($query,mysql_errno(),mysql_error); $id = mysql_insert_id($cn); $uploaddone="sucess"; if($uploaddone=="sucess") { header("location:step2.php"); } else { header("location:step1.php?error=ix"); }?>[/code] Quote Link to comment Share on other sites More sharing options...
gmwebs Posted October 30, 2006 Share Posted October 30, 2006 If this doesn't work, then it is likely that your $pingvin variable is not the temporary file. You would then need to access the $_FILES array to get the temp file.[code]<?php session_start();require_once("include/config.php");$new_width=100; //Image width Change if needed$new_height=100; $userId=$_SESSION['user_id'];$pingvin_new = "testfile.jpg"; //make the extension the same as you are uploading for nowcopy($photos_uploaded['pingvin']['tmp_name'], "Uploadimages/" . $pingvin_new); $add1="Uploadimages/$pingvin_new"; $thumbnailpath1="thumnailimages/$pingvin_new"; $query="insert into myspaceuserpicture (UserID,UseImagepath,Userthubnailpath,imagetype) values ('$userId','$add1','$thumbnailpath1','1')"; mysql_query($query) or handle_mysql_error($query,mysql_errno(),mysql_error); $id = mysql_insert_id($cn); $uploaddone="sucess"; if($uploaddone=="sucess") { header("location:step2.php"); } else { header("location:step1.php?error=ix"); }?>[/code] Quote Link to comment Share on other sites More sharing options...
johntp Posted October 31, 2006 Author Share Posted October 31, 2006 [code]<?php session_start();require_once("include/config.php");$new_width=100; //Image width Change if needed$new_height=100; $userId=$_SESSION['user_id'];$pingvin_new = "testfile.jpg"; //make the extension the same as you are uploading for nowcopy ($pingvin, "Uploadimages/$pingvin_new"); $add1="Uploadimages/$pingvin_new"; $thumbnailpath1="thumnailimages/$pingvin_new"; $query="insert into myspaceuserpicture (UserID,UseImagepath,Userthubnailpath,imagetype) values ('$userId','$add1','$thumbnailpath1','1')"; mysql_query($query) or handle_mysql_error($query,mysql_errno(),mysql_error); $id = mysql_insert_id($cn); $uploaddone="sucess"; if($uploaddone=="sucess") { header("location:step2.php"); } else { header("location:step1.php?error=ix"); }?>[/code]worked. It made a file called testfile.jpg, which is a great progress. Quote Link to comment Share on other sites More sharing options...
gmwebs Posted October 31, 2006 Share Posted October 31, 2006 Ok good, so did the actual file open up as an image after uploading too? This then means that $pingvin is being defined in one of the other scripts. Could you try to find where it is being defined, and then post the code for that script? Then we can look at automatically creating that filename and extension based on what the user uploads. Quote Link to comment Share on other sites More sharing options...
johntp Posted October 31, 2006 Author Share Posted October 31, 2006 yea they opened as files, but they didn't resize to 100x100. I did a search for pingvin in all source code in the entire folder and nothing except uploadphoto and step1. Quote Link to comment Share on other sites More sharing options...
gmwebs Posted October 31, 2006 Share Posted October 31, 2006 Wow... ok... So let me get this straight... You want a user to upload a photo, and then you want your script to resize it and copy it to the Uploaded files folder - all using just that code you supplied?It is quite a bit more complex than that I'm afraid!If you want to resize your image on the fly, you would need to make sure that your host has GD or ImageMagick support. You would then need to add in quite a bit more code into your script. I have a nice example of one I wrote a while back, but unfortunately I don't have access to it from where I am at the moment. Unless someone else can point you in the right direction from here, or maybe if you can look on google for some PHP image resize scripts, you would have to wait until I can get a chance to post that script of mine. Quote Link to comment Share on other sites More sharing options...
johntp Posted November 7, 2006 Author Share Posted November 7, 2006 k i used a diff section of uploading to use as the main one. Everything uploads great and pics are resized, but im getting an error.Error:[code]dest=Warning: copy(Water lilies.jpg): failed to open stream: No such file or directory in /mounted-storage/home23b/sub003/sc21754-QIFR/www/mainscript/uploadphoto.php on line 26Warning: getimagesize(): Unable to access _backup.jpg in /mounted-storage/home23b/sub003/sc21754-QIFR/www/mainscript/uploadphoto.php on line 27Warning: getimagesize(_backup.jpg): failed to open stream: No such file or directory in /mounted-storage/home23b/sub003/sc21754-QIFR/www/mainscript/uploadphoto.php on line 27Warning: Cannot modify header information - headers already sent by (output started at /mounted-storage/home23b/sub003/sc21754-QIFR/www/mainscript/uploadphoto.php:65) in /mounted-storage/home23b/sub003/sc21754-QIFR/www/mainscript/uploadphoto.php on line 128[/code] Quote Link to comment Share on other sites More sharing options...
johntp Posted November 7, 2006 Author Share Posted November 7, 2006 well i can't seem to upload my pages so go to [url=http://www.collegeroomm8.com/uploadphoto.txt]www.collegeroomm8.com/uploadphoto.txt[/url] and [url=http://www.collegeroomm8.com/step1.txt]www.collegeroomm8.com/step1.txt[/url] 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.