Script not working on server

Discussion in 'PHP' started by areaba, Jul 31, 2009.

  1. #1
    Hi,
    I have written some code in admin section to insert the wallpaper in the folder. Only the pic name saved in the db. Locally this code works good , add the wallpaper and show it in my local server. but the problem is that when i shall upload it on the server and try to upload some file , it shows some warning, admin section show an entry but image is not displayed . Kindly help me to solve this issue. I have put the code.
    	if($_POST){
    		$catid	=	trim(_POST("catid", "", false));
    		
    		if($catid != ""){
    			$q	=	mysql_query("INSERT INTO `wallpapers` SET 
    									`catid` = '$catid'");
    			if($q){
    				$lastid	=	mysql_insert_id();
    				
    				// uploading picture
    				if($_FILES['pic']['error'] == "UPLOAD_ERR_OK"){
    					$picname	=	$_FILES['pic']['name'];
    					$fileext	=	getFileExtention($_FILES['pic']['name']);
    					$picname	=	str_replace(".$fileext", "$lastid.$fileext", $picname);
    					
    					$picpath	=	"../" . $WALLPAPER_PIC_DIR . $picname;
    					move_uploaded_file($_FILES['pic']['tmp_name'], $picpath);
    					mysql_query("UPDATE `wallpapers` SET `pic` = '$picname' WHERE `id` = '$lastid'");
    				}
    			
    				redirect("insert-wallpaper.php?er=done");
    			}else
    				redirect("insert-wallpaper.php?er=not");
    		}else
    			redirect("insert-wallpaper.php?er=empty");
    	}
    PHP:

     
    areaba, Jul 31, 2009 IP
  2. areaba

    areaba Peon

    Messages:
    62
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Warnings are:

    Warning: move_uploaded_file(../wallpapers/Lottery-01263.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/funclue/public_html/admin/insert-wallpaper.php on line 28

    Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpHxFp60' to '../wallpapers/Lottery-01263.jpg' in /home/funclue/public_html/admin/insert-wallpaper.php on line 28

    Warning: Cannot modify header information - headers already sent by (output started at /home/funclue/public_html/admin/insert-wallpaper.php:28) in /home/funclue/public_html/functions.inc.php on line 34
     
    areaba, Jul 31, 2009 IP
  3. codebreaker

    codebreaker Well-Known Member

    Messages:
    281
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    110
    #3
    Check if walpapers folder is chmoded 777.
     
    codebreaker, Jul 31, 2009 IP
  4. areaba

    areaba Peon

    Messages:
    62
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    how can i check that?
     
    areaba, Jul 31, 2009 IP
  5. areaba

    areaba Peon

    Messages:
    62
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks dear yes its work now.
     
    areaba, Jul 31, 2009 IP
  6. codebreaker

    codebreaker Well-Known Member

    Messages:
    281
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    110
    #6
    :)...ok i'm glad i could help you
     
    codebreaker, Jul 31, 2009 IP