I am using Uploadify jQuery plugin for file upload.Here there is no browse button used.
it will upload the file using ajax on click event.So There is no file temp path is displaying.So i want to make it display.
So, I try to get file temp path using $_FILES['uploadfile']['tmp_name']. But it just return something like this /tmp/phpclqHXj.But i want display actual temp path like C:\Users\Diamantino\Desktop\file.jpg.Can i get this using php. any option in uploadify
plugin, anyway to get jquery or js.Any help would be appreciated.
My Browse button.
Thanks
There is no way to get the full path to the file from your user's computer. You can get the file name (in your example that would be "file.jpg") using $_FILES['uploadfile']['name']. Security issues would arise if you could get information about your user's local folder structure when they upload a file, so web browsers are very unlikely to send that data. If there is some browser that does send it, it won't appear in the $_FILES superglobal, nor will there be any other easy way to access is in php.
At the very least, you're looking for the filename found under:
$_FILES['uploadfile']['name']
Instead of C:\Users\Diamantino\Desktop\file.jpg, this will return the filename: file.jpg
However, with the use of simple Javascript, you may be able to accomplish getting the entire file path. With some logic on your end, you may be able to get the file path only when the file is uploaded. Here is an example, and some clarity on implementation.
Related
Is there a way that I can allow a user to upload a file by providing the filename/directory for the file in a get variable (or some way other than using a form)?
Essentially, I'd like the user to be able to do something like this:
http://example.com/upload.php?file=C:/files/myFile.txt
and have upload.php handle the upload.
I've been looking at this to try to figure out how to do this, along with a couple of other resources, but they're all focused around using forms.
I need to be able to allow an app to go to my php page and provide a file to be uploaded without a prompt.
It doesn't have to be in a GET, but I CANNOT PROMPT for a file.
Any thoughts?
Sorry, that's not possible. You can upload file using post request. Why are you trying to send data using get request?
I've been searching for a good 3 hours, and I'm stumped on how to do something I think is pretty simple (famous last words...)
Basically, I'm building a site that allows the user to upload a pdf file. The URL of this file is stored in a database, along with the name and a few other details. I am trying to work out how to either:
-Provide an "upload" box/button/area that a user can select a file, upload it, and then have the URL of where the file was uploaded stored in a database.
OR
-Use a separate upload script, and have the user upload the file. Then, (on a possibly separate page, I don't mind) provide a file browser, which would allow the user to browse a directory, and select a file, with the url of that file passed through to the PHP form.
I don't mind which way it is done, as long as the desired outcome of having a file uploaded and the url added to a database.
Or am I out of the reach of PHP? Is my best bet uploading files via a bare php uploader, then manually entering the url of the file uploaded into a textbox on a php form?
Any help is much appreciated!
create a htmlform, make sure to set enctype to a value of
"multipart/form-data"
in PHP you should be able to get the file namefrom the $_FILE global variable
save it to a directory on the server.
the url of your document will we http://serverroot/{directory name}/filename.pdf -> directory name is the name of the directory on the serve you saved the file in
I'm wanting to create a website that allows an user to put a link in a field and once the user submits the form, the "image" link added to the field will be remote uploaded to my server (to the path I specified in my server).
A friend of mine did this once, and he told me that he used the file_get_contents() function to get this working, but I cannot figure out how I'd do it.
Any help would be appreciated.
Thanks.
file_get_contents() will read file contents into a variable.
if you need to copy file to your server, use copy() instead.
copy($_POST['link'],basename($_POST['link']));
so I have this form where I add item to my DB.
Fiedls are:
Name, Description, Image.
Problem is with image, I want to send the new values via AJAX using jQuery to my submit file. Reason for this is to not refresh any page. Everything is fine except IMAGE because browsers keep making the path private ex. "C:\fakepath\myImg.png".
Is it possible to somehow send my image path, because it works with default <form method="post...></form>, only problem is that it is refreshing the page, that's why I want to use AJAX.
Sorry, my native language is not English so maybe you didn't understand me clearly :)
I'm after full path to UPLOAD the image in my submit file. I can't upload image without knowing it's full path, can i?
You can use jquery.form plugin to upload forms without reloading the page.
Examples: http://www.malsup.com/jquery/form/#code-samples
The browser keeps making it a "private" path because the browser client has no knowledge of your server structure and it only knows the path where it is stored on the client machine. The upload goes to a temporary location on your server and it is up to you on the server side to move it from the temporary path to the place you want to store the file,
So in that sense, no you can't specify the destination path using AJAX.
In addition, you never want to allow the client to specify a location on your server. Even allowing them to specify the name that the file will be stored as is a potential security risk.
Is there a way to pass a list of files to fancy upload via java script rather then using the browse button and dialog?
http://digitarald.de/project/fancyupload/#docs
Thanks in advance.
You mean that you want to be able to specify an arbitrary path on the user's machine to upload?
Well, for obvious reasons, that's completely impossible.
If you disagree, think about what would happen if a website made a hidden file upload, set its path to "%USERPROFILE%\Cookies\index.dat", or some other path, and submitted it automatically.
What you might want to look into is to use Flash or Java plugins to upload the file. That will provide you the access to UI changes and so on
Example: http://imageshack.us/ homepage.