bindiya Posted April 18, 2011 Share Posted April 18, 2011 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."; } } } Quote Link to comment https://forums.phpfreaks.com/topic/234041-problem-uploading-images-to-my-server/ Share on other sites More sharing options...
bindiya Posted April 22, 2011 Author Share Posted April 22, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/234041-problem-uploading-images-to-my-server/#findComment-1204765 Share on other sites More sharing options...
Drummin Posted April 22, 2011 Share Posted April 22, 2011 Hey I'm no expert but it would seem to me that you could just back out of the Admin section with something like this. Sorry if that doesn't help. $upload_dir = "../images"; move_uploaded_file ($_FILES['photo']['tmp_name'],"$upload_dir/$basename"); Quote Link to comment https://forums.phpfreaks.com/topic/234041-problem-uploading-images-to-my-server/#findComment-1204772 Share on other sites More sharing options...
bindiya Posted April 22, 2011 Author Share Posted April 22, 2011 i tried to give the full sites name, but then i got the error message cannot give full path address to the move_uploaded_file() that is the worrying matter...... Quote Link to comment https://forums.phpfreaks.com/topic/234041-problem-uploading-images-to-my-server/#findComment-1204789 Share on other sites More sharing options...
Drummin Posted April 22, 2011 Share Posted April 22, 2011 Can't you just change the target? $target = "../pics/"; OR $target = "../images/"; Quote Link to comment https://forums.phpfreaks.com/topic/234041-problem-uploading-images-to-my-server/#findComment-1204903 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.