Jump to content

Problem uploading images to my server


bindiya

Recommended Posts

I have a php website  with two parts the client part and an admin part

in the client part or the viewers end , i need to show the details of products  with description and an image (in the front page).

The details are entered though the admin part.

 

My problem is the image uploaded goes to the folder in the admin folder but in the home page the images are taken from the images folder suitated in outside the admin folder . How can i upload images or photos to the folder outside the admin though the admin pages.

Pasting my code here

 

$target = "pics/";  [color=red]//this is created in the admin folder, i need to change here that is keep the folder outside the admin folde[/color]r
						 $target = $target . basename( $_FILES['photo']['name']);
						 $pic=($_FILES['photo']['name']);
						  $image=$pic;
                                                          $box_num =$_POST['box_num'];
				                   $query11 = "update photo_table set  page_head='$page_head',image='$image' where id='$box_num'";
						  $result11 = mysql_query($query11);

		  if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { 
 echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; } 
   }else { 
    
	 echo "Sorry, there was a problem uploading your file.";
	  } 
}
  }




 

Link to comment
https://forums.phpfreaks.com/topic/234041-problem-uploading-images-to-my-server/
Share on other sites

I am making more clear abvout the above doubt.

The image upload is done by the admin. and the admin is  able to upload images to the  admin/images folder .But admin  wants the images to be uploaded to the www.abc.html/images folder.

 

Posting the code again




$target = "pics/";  [color=red]//this is created in the admin folder, i need to change here that is keep the folder outside the admin folde[/color]r
						 $target = $target . basename( $_FILES['photo']['name']);
						 $pic=($_FILES['photo']['name']);
						  $image=$pic;
                                                          $box_num =$_POST['box_num'];
				                   $query11 = "update photo_table set  page_head='$page_head',image='$image' where id='$box_num'";
						  $result11 = mysql_query($query11);

		  if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { 
 echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; } 
   }else { 
    
	 echo "Sorry, there was a problem uploading your file.";
	  } 
}
  }

 

Any idea?? I just made my doubt so simple, please dont consider this as a re posting. :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.