Jump to content

help with img uploading


johntp

Recommended Posts

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:

[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 ??????
Link to comment
Share on other sites

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">&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>







[/sup]
Link to comment
Share on other sites

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

?>
[/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.
Link to comment
Share on other sites

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

?>
[/code]
Link to comment
Share on other sites

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?
Link to comment
Share on other sites

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

?>

[/code]
Link to comment
Share on other sites

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

?>
[/code]
Link to comment
Share on other sites

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

?>

[/code]

worked. It made a file called testfile.jpg, which is a great progress.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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 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
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.