0

I am using xampp on my local desktop and created an folder named image.

Path: C:/xampp/htdocs/mycreation/ch-5/images/.

In ch-5 folder i have my php file and also images folder.

now how can i define a $target_dir to that images folder.

1
  • use move_uploaded_file function to move the uploaded file to the desired location. Commented Mar 20, 2017 at 6:13

4 Answers 4

1

You can define target dir something like:

$target_dir = "images/";
Sign up to request clarification or add additional context in comments.

Comments

0

$target_dir = $_SERVER['DOCUMENT_ROOT']."/mycreation/ch-5/images/";

Comments

0

create one folder(uploads) inside htdocs/ch-5 and try this code,,..

  move_uploaded_file($_FILES['file']['tmp_name'],"uploads/".$_FILES['file']['name']);
    $image_path="uploads/".$_FILES['file']['name'];

Comments

0

for uploading files you can use move_uploaded_file function, which takes the current file and the location you want to save that file.

$file_name = $_FILES['image']['name'];
$file_tmp = $_FILES['image']['tmp_name'];
$target_dir = "images/"; //images directory

if (move_uploaded_file($file_tmp, $target_dir . $file_name)) {
     echo "Uploaded file";
else
    echo "Failed to upload image";

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.