0

My goal is to create a photo path like this,

html: "<img src='[add-file-path-here]" + file["name"] + "' width='50' />"

This area

[add-file-path-here]

needs to be users/$username

$username is a hidden field in in the page so should be easily accessible. The form looks like this,

 <form id="upload" method="post" action="actions/upload.php" enctype="multipart/form-data">
<input type="hidden" name="username" value="<?php echo $username; ?>" id="username">

in this JS file how can I add the $username variable to the image path. That way no matter which user is logged in it always shows the rite path to that users images

So to be clear, in the html form I have a hidden field call $username, I want to create a img path in the JS file

 html: "<img src='[add-file-path-here]" + file["name"] + "' width='50' />"

How can I swap out [add-file-path-here] for users/$username

1 Answer 1

2

Just read the form element value with jquery?

var path = "users/" + $("#username").val();
// ....
html: "<img src='" + path + file["name"] + "' width='50' />"
Sign up to request clarification or add additional context in comments.

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.