PHP File Upload Without Form - php

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?

Related

Add a progress bar in Laravel form?

I am working on a simple profile update form and I need to have a progress bar for the photo upload. I am new to this and have no clue where to begin.
I am trying to upload the file as an input field in the form with the type as file. With larger files, I cannot track if the upload has failed or frozen and would like a progress bar.
I can create a bar which is filling according to percentage but I still need to have the information from the server which I don't understand how.
I read somewhere that PHP 5.4 and above provides this information via the $_SESSION in the form of session.upload_progress.name but I also read somewhere else that Laravel does not use the conventional session and this won't work.
Is there a way to get this to work. I don't have a multiple image upload so I don't wish to install those third party libraries out there. I just want to keep it simple and somehow fetch the upload information from the server.
What is the simplest way to go around this problem?
The simplest way is to do it via jQuery and AJAX - using something like http://www.dropzonejs.com/ - which is awesome and very easy to use

How to get file temporary path in php while file upload

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.

How to restrict file types for a user in a web browser

Hi i have a question that is almost like other questions but with a small but very important difference.
How can i restrict file types for user with a popup showed in the browser.
The standard file input of html can limit that with a command but it does not work in all browser so it is not an option.
I do not want to validate the file extension after the user has chosen a file but before that, when he is choosing.
Founded this http://demo.swfupload.org/v220/index.htm, but it uploads the file after the user has chosen it, i do not want to do that, i want to upload it after the user submits the form.
So the problem looks like this that there are some ways of not letting the user send a not valid file but they are not good because, one is that i validate after the user have chosen the file and the other is that i upload the file before the user submits the form.
I just want a simple thing to not letting to "chose" a not valid file, it does not matter if it will be made with java script or flash, just let it work.
maybe you have some ideas on how to do it because i searched the whole internet and did not found any solution.
Uploadify supports that feature and is very customizable. You should have no problems setting it up in a way that it uploads the file when the user submits.
you can put a condition on the action file of php where all the fields get by submit the page.at that time you can put validation for the file type. if the file type is not as you mentioned then redirect the error message and let user to make try again.
Thanks.
<input type="file" accept="text/html,image/jpeg">
Also: Mozilla`s doc
Not sure if that's what you're after, but Flash FileReference.browse() method has a FileFilter structure as an input argument, and there you can limit the types of files that the upload dialogue will show.
flash.net.FileReference

Amazon S3 File Uploads

I can upload files from a form using post, but I am trying to find out how to add extra fields to the form i.e File Description, Type and etc.
Also can I upload more than one file at once, I know it says you can't using post in the documentation but are there any work arounds?
Thanks in Advance
In regards to uploading multiple files, are you uploading directly to S3 using POST, or posting to s3 using CURL or a similar lib from your own server?
Why are you adding these extra inputs? If posting directly to S3, you cannot post any inputs that aren't specified as required or optional in the S3 documentation. Any form elements that don't start with "x-ignore-" and aren't required/optional for S3 post upload WILL cause an error to be returned from S3, without uploading your file. If you have elements in the form that can cause this error and they are important to leave in the form before it is submitted (being used as input for an ajax call, etc), then simply append the name of these form elements with "x-ignore-" or delete them from the form.
You have control over a few things, such as the name the file is served with and type by usign the Content-Type and Content-Disposition elements. Take a look at this:
http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1434
You can append your additional information to the "return url" you send alongside your request to Amazon.
Be aware that doing this may expose sensitive information about your app logic to the user in the form of an URL. One thing you can do to avoid/hide this is to capture all GET variables on return, save them, and redirect user to a summary page.
This won't block smarter users form learning your GET variables, but will hide them from 99% of the public.

Fancy Upload without file browser

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.

Categories