need help with php video script upload picture

Discussion in 'PHP' started by bikerboys, Nov 29, 2007.

  1. #1
    hi every one im need alittle help here im working with a video script and it wont upload the images i keep getting this error in the error log

    PHP Warning: move_uploaded_file() [<a href='function.move-uploaded-file'>function.move-uploaded-file</a>]: Unable to move '/tmp/phpqjKz01' to '/home/usr/public_html/photo/474ee2ef5e1811058.jpg' in /home/junkies/public_html/admin/pronlinks_add.php on line 26

    PHP Warning: move_uploaded_file(/home/usr/public_html/photo/474ee2ef5e1811058.jpg) [<a href='function.move-uploaded-file'>function.move-uploaded-file</a>]: failed to open stream: No such file or directory in /home/junkies/public_html/admin/pronlinks_add.php on line 26

    here is the page any help would be great
    <?
    
    	include_once "/home/junkies/public_html/config/connection.php";
    	
    	if($_SESSION['adminid']=="")
    	{
    		echo "<script>window.location='index.php';</script>";
    	}
    	if(isset($_REQUEST['add']))
    	{
    			$category	=	$_REQUEST['category'];
    			$name		=	$_REQUEST['name'];
    			$user		=	$_REQUEST['user'];
    			$desc		=	$_REQUEST['desc'];
    			$link		=	$_REQUEST['link'];
    			$date       =   date('Ymd');
    			$time       =   date('H:i:s');
    			$img1       =   $_FILES['file1']['name'];
    
    	    	if($img1!='')
    				{
    						$uniq=uniqid($uniq);
    						$img1=$uniq.$img1;
    						$uploadfiles = $path.$img1;					
    
    						move_uploaded_file($_FILES['file1']['tmp_name'],$uploadfiles);
    		
    				}
    
    			$str="INSERT INTO `pron_links`(`user`,`category`,`name`,`desc`,`picture`,`link`,`date`,`time`,`status`) VALUES ('0','$category','$name','$desc',
    
    			'$img1','$link','$date','$time','1')";
    
    			$Q($str);
    
    			echo "<script>window.location='pronlinks.php?add=1';</script>";
    
    	}
    
    	if(isset($_REQUEST['cancel']))
    	{
    
    			echo "<script>window.location='pronlinks.php';</script>";
    	}
    
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <script>
    function check()
    {
    	if(document.form1.category.value=="select")
    	{
    		alert("Enter category");
    		document.form1.category.focus();
    		return false;
    	}
    	if(document.form1.name.value=="")
    	{
    		alert("Enter Link Name");
    		document.form1.name.focus();
    		return false;
    	}
    
    	if(document.form1.desc.value=="")
    	   {
      		if (confirm("Description is empty, Do you Want to Continue ?")==true)
        		return true;
      		else
    			document.form1.desc.focus();
        		return false;
    		}
    
    }
    
    </script>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Admin Panel</title>
    <link href="common/stylesheet.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <th align="left" valign="top" scope="row"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <th colspan="2" scope="row"><?php include_once "common/header.php";?></th>
            </tr>
            <tr>
              <th width="22%" align="left" valign="top" scope="row"><?php include_once "common/left.php";?></th>
              <th align="left" valign="top" scope="row"><table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
                  <form action="" method="post" enctype="multipart/form-data" name="form1" id="form1" >
                    <tr>
                      <td><fieldset>
                        <legend style="color:#0000FF; font-weight:bold;">Porn Links Add</legend>
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td align="right" valign="middle" class="inner_tr">&nbsp;</td>
                            <td class="inner_tr">&nbsp;</td>
                            <td height="40" class="inner_tr">&nbsp;</td>
                          </tr>
                          <tr>
                            <td width="36%" align="right" valign="middle" class="inner_tr">Category:</td>
                            <td width="2%" class="inner_tr">&nbsp;</td>
                            <td width="62%" height="40" class="inner_tr"><strong>
                              <? 
    	 					 	$qu		=		"SELECT `id`,`name` FROM `pron_category`";
    	  						$rs		=		$Q($qu);
    						 	?>
                              <select name="category" value="<? echo $_REQUEST['name'];?>">
                                <option value="select">select</option>
                                <? 
    							while($dis=$F($rs))
    							{
    							?>
                                <option value="<? echo $dis['id']?>"> <? echo $dis['name'];?></option>
                                <? } ?>
                              </select></td>
                          </tr>
                          <tr>
                            <td align="right" valign="middle" class="inner_tr">Name:</td>
                            <td class="inner_tr">&nbsp;</td>
                            <td height="40" class="inner_tr"><label>
                              <input type="text" name="name" />
                              </label></td>
                          </tr>
                          <tr>
                            <td align="right" valign="middle" class="inner_tr">Description:</td>
                            <td class="inner_tr">&nbsp;</td>
                            <td height="40" class="inner_tr"><label>
                              <textarea name="desc" cols="30" rows="10"></textarea>
                              </label></td>
                          </tr>
                          <tr>
                            <td align="right" valign="middle" class="inner_tr">Picture Upload: </td>
                            <td class="inner_tr">&nbsp;</td>
                            <td height="40" class="inner_tr"><label>
                              <input type="file" name="file1" />
                              </label></td>
                          </tr>
                          <tr>
                            <td align="right" valign="middle" class="inner_tr">Link:</td>
                            <td class="inner_tr">&nbsp;</td>
                            <td height="40" class="inner_tr"><label>
                              <input type="text" name="link" />
                              </label></td>
                          </tr>
                          <tr>
                            <td align="right" valign="middle" class="inner_tr">&nbsp;</td>
                            <td class="inner_tr">&nbsp;</td>
                            <td height="40" class="inner_tr">&nbsp;</td>
                          </tr>
                          <tr>
                            <td class="inner_tr">&nbsp;</td>
                            <td class="inner_tr">&nbsp;</td>
                            <td height="40" class="inner_tr"><input name="add" type="submit" class="button" onClick="javascript:return check();"    value="Submit" />
                              <input name="cancel" type="submit" class="button" value="Cancel" />
                            </td>
                          </tr>
                        </table>
                        </fieldset></td>
                    </tr>
                  </form>
                </table></th>
            </tr>
          </table></th>
      </tr>
    </table>
    </body>
    </html>
    
    PHP:
    thanks for any help
     
    bikerboys, Nov 29, 2007 IP
  2. drunnells

    drunnells Peon

    Messages:
    79
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Maybe a permission problem? Php can't write to /home/usr/public_html/photo in the first warning, which then causes the second warning because the file is never moved.

    Assuming this is linux/unix, you should make sure that your apache (or whatever web server you run) user has permission to write to /home/usr/public_html/photo . You can do this by changing the owner of /home/usr/public_html/photo to the user that apache runs as (in my case the user is "nobody") and giving the "user" read/write/execute permission like so:

    chown nobody /home/usr/public_html/photo
    chmod u=rwx /home/usr/public_html/photo

    Or you can take the easy way out and just make the /home/usr/public_html/photo read/writable by anyone:

    chmod 777 /home/usr/public_html/photo

    Hope this helps!
     
    drunnells, Nov 29, 2007 IP
  3. bikerboys

    bikerboys Well-Known Member

    Messages:
    308
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    105
    #3
    well thanks for trying i have the all ready set to 777 so im kinda lost
     
    bikerboys, Nov 29, 2007 IP
  4. drunnells

    drunnells Peon

    Messages:
    79
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Does every directory above /home/usr/public_html/photo have execute and write permission for your apache user? Can you login or "su" to your apache user and write to a file in /home/usr/public_html/photo to rule out any permission problems?
     
    drunnells, Nov 29, 2007 IP
  5. bikerboys

    bikerboys Well-Known Member

    Messages:
    308
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    105
    #5
    i beleive so yes
     
    bikerboys, Nov 29, 2007 IP
  6. bikerboys

    bikerboys Well-Known Member

    Messages:
    308
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    105
    #6
    i get this error so far from the admin panel im going to try it as a user right now
     
    bikerboys, Nov 29, 2007 IP
  7. bikerboys

    bikerboys Well-Known Member

    Messages:
    308
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    105
    #7
    now i get this error on that one

    Thu Nov 29 14:56:45 2007] [error] PHP Warning: move_uploaded_file() [<a href='function.move-uploaded-file'>function.move-uploaded-file</a>]: Unable to move '/tmp/phpTBdYz2' to '/home/usr/public_html/photo/474f27a462e2bteenager_puts_nail_through_his_hand.gif' in /home/junkies/public_html/submit_userlink.php on line 17

    [Thu Nov 29 14:56:45 2007] [error] PHP Warning: move_uploaded_file(/home/usr/public_html/photo/474f27a462e2bteenager_puts_nail_through_his_hand.gif) [<a href='function.move-uploaded-file'>function.move-uploaded-file</a>]: failed to open stream: No such file or directory in /home/junkies/public_html/submit_userlink.php on line 17
     
    bikerboys, Nov 29, 2007 IP
  8. drunnells

    drunnells Peon

    Messages:
    79
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Those last errors are really the same errors from above. move_uploaded_file() can't move the file from /tmp to /home/usr/public_html/photo for some reason. There really are not too many reasons a file would not be able to be moved if it exists in /tmp.. in fact, the only reasons i can think of would be if the permissions on /home/usr/public_html/photo or one of it's parent directories does not allow it or if the temporary file in /tmp is not read/writable. If you are certain that the problem is not with permissions on /home/usr/public_html/photo or its parent directories, check to see if /tmp/phpTBdYz2 even exists and its permissions allow your apache user to read/write to it...
     
    drunnells, Nov 29, 2007 IP
  9. bikerboys

    bikerboys Well-Known Member

    Messages:
    308
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    105
    #9
    i ad a setting messed up i think i fixed it thanks for help
     
    bikerboys, Nov 29, 2007 IP