PHP File Upload WITHOUT Form or JQUERY Post - php

I want to have a page where the user makes a request using a known format through CURLing a URL, and the file they provide is then uploaded to the server.
The URL would be like this:
http://localhost/fileupload.php?FilePath=c:\testfile.txt
However, all the guides online work off of form submission or JQuery AJAX requests - can this be achieved with pure PHP?

Related

HTML/PHP/JS - Upload File while filling Form

i have a form with a Photo Upload Input. I want the picture to be uploaded before submitting the form to speed up the submit.
the form should be able to upload multiple files and should show a progressbar + preview.
how i can do this?
MetinKale38
You can do this pretty easily now in HTML5 using XMLHttpRequest with a multipart form and the file element. XMLHttpRequest now supports progress events which you can handle in your Javascript code. Here is a link to an excellent article with detail and code examples http://www.matlus.com/html5-file-upload-with-progress.
Note that your PHP code must still treat each file independently, but that is transparent to your JavaScript - it will simply make multiple posts to the server.

Passing file upload jquery and ajax

I am trying to upload file Jquery with ajax using php. If i passing Jquery data i not able to retrieve the file upload data how can i pass jquery file upload data to ajax. Kindly some on help me how can upload file through jquery ajax with php..
You cannot AJAX upload.
It's basically a fake AJAX to make it look like it is AJAX uploading.
In reality what happens is that the upload form is given a target of a nearby iframe. This makes it look like it is AJAX uploading when in reality it isn't.
The iframe is normally given a JS function within size of it that triggers a function in the parent windows which shows some kind of message say "Thank you for your upload".
Of course this is only really basic functionality and you'll need to Google search for more exampls, fortunately there are tonnes out there.

Difference between Ajax upload and Normal upload

i have a doubt with the upload system in PHP.
What is the difference between Normal Upload [ without ajax ] and Ajax Upload ?
By using Javascript i can send values to the server ,is it possible in the case of Files ?
Is there any limitation for this ? and i found that so many uploaders are using FLASH for to upload FILES,
ex:Gmail,uploadify.....
How can i build a basic uploader with JQUERY/javascript ? also i heard that i cant send FILE by a XHR request.
i am using Codeigniter Framework.
Expecting Possible duplicate or other refference
Main Goal Of this Question is to build my own uploader for my current project[neat and clean]
Okay, AJAX upload is basically just that, it's going through Javascript. The difference is that the page does not upload, and you can carry on with other things as it works. It generally makes for a better user experience in my opinion, it feels more seamless
On the other hand, it only works for newer browsers. Firefox, Chrome, Opera have it, but not IE (maybe Safari?). It also works well with drag and drop. I once made an image uploader inside a text editor, where it popped up a table with your currently uploaded images, you clicked one and it added it to the textbox or you dragged a new image into a box and it uploaded and displayed it straight away. It was beautiful.
Here's the plugin I used to help me
http://dropup.net/
Edit: No limitations either, you can even send plain binary data in
well as if you want to upload the file with jquery ajax request then use ajax form plugin as well,
this link Ajax From will help you to understand and implement on your page,
but i don't know about codignighter frame work cause i don't have experience of that. And ajax is the best way to distribute the process into different parts with any extra load on the page i mean ajax request will work on the back end..

Submitting a file via AJAX

Started with ajax last week. How would I upload an image using it. What I want to do is upload an image. I would imagine using input type="file" then the PHP file needs to collect the URL of the newly uploaded image. And return it to the ajax function to put the URL inside an <img src"" >
How would one do that.
Any ideas?
Marvellous
I would recommend Valums ajax upload script. If it comes across a browser that does not support upload via ajax it will gracefully handle them via hidden iframe uploads
Note: IE (all flavors) does not support file uploads via ajax and will therefore default back to iframe upload.
You can't send files through AJAX consistently. You will need to submit your form into a hidden iframe to simulate an AJAX transaction. Using an iframe ensures that your application will be compatible with all browsers - particularly the IEs.
After digging through my bookmarks a simple script to facilitate this might be found with http://valums.com/ajax-upload/ but I have not used it.

Can I post a temporary file name of the file that is being uploaded using jquery

I need to post a form which includes personal details and I need to upload an attachment file also I need to achieve this using AJAX.
How can I upload a file using AJAX , I need to post the personal detail as well as upload a file at the same time using AJAX , how can I do this?
You can't upload files with AJAX because you can't do multi-part encoded requests - that's a limitation of the XMLHttpRequest API.
Workarounds for this typically involve using an IFRAME that is the target of a form that handles the actual file upload as a separate sub-process to the overall form. The response loaded in the IFRAME then communicates back to the DOM in the parent/calling page with information about the uploaded file.
If you add a hidden iframe on the page
<iframe name="iframe1" ... />
And the change the target on your form to post to the iframe
<Form traget="iframe1" ...>...</form>
You can upload and post the data to the page. You can also use javascript (JQuery) to get hook into the events of the iframe.
To get a upload progress meter, use the php uploadprogress module. It works great!
http://pecl.php.net/package/uploadprogress
and
http://bluga.net/projects/uploadProgressMeter/
Here is a link i found that may help:
http://www.finalwebsites.com/forums/topic/php-ajax-upload-example

Categories