Serge Holmberg
asked on
php ajax
For security reason I store client files outside of root directory. To view files I use html form generated by Ajax. There is no problem to use that form to upload files to the server. The problem is to get it back and display on a generated form. All other information I can get by PHP file using XML header and display it on a form. To display downloaded file in PHP I can use readfile($uploaddir."file_ name") function. But how can I pass downloaded file to my generated html form?
You should have two things occur at the same tine, the storage of the file within the file using a unique naming convention to avoid the possibility of one uploaded file clashing with an existing. At the same tine an entry in the backend database should record this file.
Part of the data passed ... Could be the id column representing the file.
<inout type=hidden name=file value=1253356546>
Part of the data passed ... Could be the id column representing the file.
<inout type=hidden name=file value=1253356546>
If you are asking how can you pass a file to the browser when it exists outside the root then you need an intermediary page that loads that file and streams it to the browser (i.e. not directly linking to it)
http://php.net/manual/en/function.readfile.php
http://php.net/manual/en/function.readfile.php
ASKER
Thank you. Question a little bit different, but your answer is helpful! Question was about how to pass downloaded from server file using PHP to html form using Ajax and XML tags inside PHP.
What is the file, an image, or you need to pass a reference to the file when the user clicks, the file is displayed. or as was suggested the file is pushed out to the page ..
ASKER
An image. Not a reference, because the file is outside of root directory. I already found solution. Thank you. If you need, I can pass the solution to you. But I think you know it. It is up to you.
Post it, because you can't direct link an image not in your webroot
Or maybe we're all not understanding what you meant
Or maybe we're all not understanding what you meant
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Can I use a POST method instead of GET method?
You could, but to post you have to define a complete form
Where method=post ...
Where method=post ...