resume the broken upload - php

How to manage to write an application (JS + PHP) that would let the user resume the broken upload so as not to reload it?
N.B. No frameworks are acceptable.

No, you cant do that simply by using JS+PHP. When submitting a form the browser submits the whole file, you cannot tell it to sumbit only parts of it.
However, you may be able to do what you want by using a combination of Flash or Java+PHP, but you have to override the uploading routine implemented by PHP...

Related

Can I know on PHP (without javascript) if a user has right-clicked oppening a link?

I was coding from some ideas collected over the web a "solution" to redirect all pdf, for example, downloads on a server to a reCAPTCHA form and, after passed, download the requested file. It is cms agnostic and works but I have one situation that downloads an incorrect file.
The code is at: https://github.com/Siot/docafi (request.php file)
I explain the process:
All .pdf requests where redirected to request.php through .htaccess:
RewriteRule ^(.+.pdf)$ request.php?file=$1 [NC,L]
If it's the first time ($_SESSION var) request.php will show you a reCAPTCHA form.
If reCAPTCHA passed -> download starts.
If error -> error message.
If reCAPTCHA was passed previously on the same session, download starts automatically.
The special case is when is the first time in the session but starts download using right-click over the link.
It downloads an incorrect file content because I can't show the reCAPTCHA form. Can I know if a user had right-clicked over the link without javascript? I want a transparent solution over the different cms/html files on the server.
Can I solve this on another way?
No, selecting 'Save as...' in the popup menu works exactly as it should - it saves whatever is fetched by the link to local disk instead of trying to show it in the browser. It's thus completely correct that it's downloading the HTML file with the reCAPTCHA instead, and there's no way to detect it, not even with Javascript - to the server it's all the same, since the browser issues the same request, it just processes the result differently. You could set a flag on onContextMenu event, but it'd just have the wrong setting anyway if you then opened the link by leftclicking it or pasting the address in the address bar by hand.
It should be possible with javascript however PHP i'm fairly confident there will be no way this can be done considering it is server side.
Look through some previous stack overflow questions like:
how to get right click event javascript

Best way to make an ajax uploading file?

I want make an uploading system with ajax [none page reload]
I have search on google, found some thing, upload in iframes , File API etc...
Old browsers havent file API, and I have some problems with iFrame uploading in IE ,
Is there any way to make it with working in all browsers?
Since your tags include jquery, I would suggest that the best solution for you would be the jQuery Form Plugin.
This plugin makes it very easy to work with forms via ajax, including forms with file upload fields. You don't need to worry about the browser API or whether it supports it or not; the plugin deals with all that behind the scenes.
There are good examples on the plugin's website, and I can confirm it works well as I've just implemented it in a project myself.
Hope that helps.
Use Uploadify. It's really simple and looks great.
http://www.uploadify.com/

PHP File Upload No Page Refresh

I know this has been asked by a few people but I haven't seen the answer. I have a php upload form for a file upload in a div tag. Is it possible to submit the form and upload the file without a page refresh? I haven't found the plugins to work because I want to submit the form with a title and other data attached as well. Any suggestions? I looked at using an iframe, but i'm not sure it will work in an upload.php wrapped in a div tag?
Here is the most simple solution you can use: Image upload without page refresh.
No obligation to use the javascript part, but it gives you the opportunity to show a notice that the transfer has been correctly done.
If you are open to jQuery and want a more open solution, I suggest you to take a look at the jQuery Form Plugin that can manage it all for you, with some extras that could be interesting.
My favourite tool for this is Uploadify. It includes real-time progress indicators, drag-and-drop, etc.
There are other, older solutions as well, including this one. That page has a simple demo that may provide a good example for how to do this on your own.
Honourable mention goes to Dave Walsh's facebook-lightbox, into which you might be able to put a file upload form. Worth a try if you like the look.
Try using something like AIM (http://www.webtoolkit.info/). And you should really get a little more experience on html, php and js.

Custom file upload button

spent hours on end searching the net but it seems im looking for one thing and finding another, either that or what i want just cannot be done. i do not want to re-style the <input type="file"> i want to create a custom button that brings up a browse window, lets the user select a file of certain types, populates a seperate text box with the file name and stores the rest of the information in a way that could be passed to a php upload script after the user has filled in the rest of the form. So in other words i want to re-invent the <input type="file">.
http://www.uploadify.com/demos/
Uploadify is a powerful and highly-customizable file upload script. In its simplest form, Uploadify is easy to get up and running with minimal effort and little coding knowledge.
Uploadify can also be modified to suits the needs of more advanced developers via the arsenal of custom options that are available.
http://www.uploadify.com/documentation/
buttonImg parameter : we can give the image/text which we wanted to show ie we can customize browse button.
This can't be done in regular html, but possible to do using flash or silverlight etc. You might want to have a look at Plupload, which is a fairly foolproof upload solution in my opinion.
This is not possible, the browse button is implemented in a very secure way, not allowing it to be styled or to do any tricks with it. This is because it could in some way allow the developer to trick the user in uploading a different file then intended.
in simple php its possible.
try this
+Create Album

Execute Javascript code when a file upload completes without requiring page refresh

I have created a file-upload form and I want to output "filetransfer succeeded" in a <div> when the file transfer is done.
This is easilly done on a normal form using Jquery and Ajax but since this is a file upload it is not possible to use ajax.
So how do I upload a file and give feedback back to the user?
Consider looking at uploadify or swfupload.
I have personally used uploadify and you can do:
$('input[type=file]').MultiFile({
list: '#DIV to update'
});
jQuery actually has a pretty slick plugin called uploadify that'll let you do this. Alternately the iFrame solution Emil suggested will work as well without any outside libraries.
You can do it in an iframe.

Categories