Jump to content


Photo

help with img uploading


  • Please log in to reply
17 replies to this topic

#1 johntp

johntp
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 27 October 2006 - 08:35 PM

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 7

and here is the code:

<? 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");
}

?>


Now Uploadimages is a folder where i want the pic to get copied in any ideas ??????
There are only 10 kind of people in the world, those who know binary, and those who don't.

#2 gmwebs

gmwebs
  • Members
  • PipPipPip
  • Advanced Member
  • 174 posts
  • LocationLondon

Posted 27 October 2006 - 09:28 PM

Well the error means something is missing. What is the value of $pingvin_new?

#3 johntp

johntp
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 29 October 2006 - 08:53 PM

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
There are only 10 kind of people in the world, those who know binary, and those who don't.

#4 johntp

johntp
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 30 October 2006 - 12:26 AM

well i was wrong in the page beforeit it calls for it.

<? 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">
<input type="file" name="pingvin"> </td>
</tr>
<tr>
<td colspan="2">&nbsp;
</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>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
</table>



<? require_once("footer.php"); ?>


</body>



</html>








There are only 10 kind of people in the world, those who know binary, and those who don't.

#5 gmwebs

gmwebs
  • Members
  • PipPipPip
  • Advanced Member
  • 174 posts
  • LocationLondon

Posted 30 October 2006 - 10:48 AM

Ok, so change your first bit of code that you included in your first post to this...

<?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 variable
exit(); //Exit the script so you can see the output

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");
         }

?>

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.

#6 johntp

johntp
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 30 October 2006 - 02:48 PM

well now after i hit upload i get this

/tmp/phpbjhWbA
There are only 10 kind of people in the world, those who know binary, and those who don't.

#7 gmwebs

gmwebs
  • Members
  • PipPipPip
  • Advanced Member
  • 174 posts
  • LocationLondon

Posted 30 October 2006 - 05:13 PM

Ok... So that looks like a temporary filename, which is good... Now try this...

<?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 TO
exit(); //Exit the script so you can see the output

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");
         }

?>


#8 johntp

johntp
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 30 October 2006 - 06:37 PM

now it's just a blank page, but the pic isn't in the directories
There are only 10 kind of people in the world, those who know binary, and those who don't.

#9 gmwebs

gmwebs
  • Members
  • PipPipPip
  • Advanced Member
  • 174 posts
  • LocationLondon

Posted 30 October 2006 - 10:32 PM

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?

#10 johntp

johntp
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 30 October 2006 - 10:56 PM

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.
There are only 10 kind of people in the world, those who know binary, and those who don't.

#11 gmwebs

gmwebs
  • Members
  • PipPipPip
  • Advanced Member
  • 174 posts
  • LocationLondon

Posted 30 October 2006 - 11:03 PM

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.

<?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 now

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");
         }

?>



#12 gmwebs

gmwebs
  • Members
  • PipPipPip
  • Advanced Member
  • 174 posts
  • LocationLondon

Posted 30 October 2006 - 11:19 PM

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.

<?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 now

copy($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");
         }

?>


#13 johntp

johntp
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 31 October 2006 - 01:33 AM

<?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 now

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");
         }

?>


worked. It made a file called testfile.jpg, which is a great progress.
There are only 10 kind of people in the world, those who know binary, and those who don't.

#14 gmwebs

gmwebs
  • Members
  • PipPipPip
  • Advanced Member
  • 174 posts
  • LocationLondon

Posted 31 October 2006 - 09:59 AM

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.

#15 johntp

johntp
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 31 October 2006 - 12:07 PM

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.
There are only 10 kind of people in the world, those who know binary, and those who don't.

#16 gmwebs

gmwebs
  • Members
  • PipPipPip
  • Advanced Member
  • 174 posts
  • LocationLondon

Posted 31 October 2006 - 12:50 PM

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.

#17 johntp

johntp
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 07 November 2006 - 04:16 PM

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:
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 26

Warning: getimagesize(): Unable to access _backup.jpg in /mounted-storage/home23b/sub003/sc21754-QIFR/www/mainscript/uploadphoto.php on line 27

Warning: 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 27

Warning: 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

There are only 10 kind of people in the world, those who know binary, and those who don't.

#18 johntp

johntp
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 07 November 2006 - 04:22 PM

well i can't seem to upload my pages so go to www.collegeroomm8.com/uploadphoto.txt and www.collegeroomm8.com/step1.txt
There are only 10 kind of people in the world, those who know binary, and those who don't.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users