the upload using the angular frontend (whichever way this is handled) sends the file data to a script on the server such as a php script (which is my preferred method). Once the php script has run I want to return to the page from which the upload was made and give a message there..I dont want the php page to display. Will appreciate some guidance on how to achieve this. Ideally what code to add to the php script. but i want upload procedure on button click or ng-click not "onFileSelect"
You can use ng-file-upload directive, with many server side samples.
Follow here: https://github.com/danialfarid/ng-file-upload/wiki/PHP-Example
Related
When a user uploads an image on my website, I want to automatically create a smaller thumbnail for it and save it - without displaying the thumbnail to the user after the upload is done.
I'm doing the thumbnail creation in a PHP file with an Image-Header and I'm currently executing this PHP file by including it in the HTML response after the upload is done:
<img src="createthumb.php?id=ID_FOR_JUST_UPLOADED_FILE" style="display: none">
That seems to be a very hacky way for me to execute the createthumb.php file and it also seems to fail sometimes - for example when the user leaves the page before he retrieves the HMTL response after the upload; or maybe because some browsers don't load images with display: none.
Either way, I'm trying to find a PHP function which executes the createthumb.php (asynchrounously) without including it in the response to the user.
include and require obviously don't work.
It sounds to me like you want AJAX.
The basic concept is that your client side script (maybe JavaScript) can generate a request for your server script (php in this case). The server script receives the request and processes it, then sends an asynchronous return message to your client script.
For your case, you could have a JavaScript function triggered on any file upload. The function sends your request to the php script and creates your thumbnail in the background without disturbing the user's current view. Take a look at the W3Schools tutorial.
http://www.w3schools.com/ajax/
I am trying to build a simple application. The first phase is selecting to upload a file from the user desktop or from the site's gallery.
The question is if the user chose to upload from the gallery, say, go to an PHP page gallery, choose a photo and then redirected to the Flash app. How would you trigger the Flash up to know there was an image chosen and it should load it?
Does PHP send a variable or create an XML based on a choice and pass it via Flash variable, or does it need JavaScript to tell Flash that if the Flash var is not empty run this function? Could you please give a sample script I could work on?
Why are you starting the upload process outside of Flash when you want to use the file inside of the Flash application? Use FileReference to initiate the file upload, save the image name locally and have the php script you hand the file off to store the file in a known place, then listen for the Complete event. From there, you should be able to load the file into Flash from your server using the path "KnownDirectory/SavedFileName" with URLLoader.
Upload file without form
Yes i used the search button but i just couldn't find the solution i need.
Is there any way to upload a file so that user wouldn't need to press any form buttons?
My first idea was to use CURL but then i remembered that CURL is server sided.
I know it's possible thru Java and/or Flash but is there any way to do that using PHP & OR Javascript?
Edit:
Thanks for clearing this for me but...
But what about PHP based FTP upload?*
No, it isn't. That would have been a huge security hole. Your best bet is really an officially signed(!) Java applet. An unsigned or a manually signed one would still emit scary warnings to the enduser before proceeding.
I have found a solution. Copy does not take local files and the example of submiting the file does not work if it is local. What you have to do is:
file_get_contents("file:///C:\img.jpg")
then write to a text file the contents in the server (for example /uploads/img.txt) and rename to the same extension of the file to see the image.
It really works with any kind of file.
what do you mean without pressing any form buttons ?
well you could do a javascript document.getElementById('FORM_NAME').submit(); if you want some function in javascript to do the upload , where FORM_NAME is the id or your current html form .
but you CAN NOT make your webpage select the file to upload , you have to let the user select the file in an <input type="file"> element .
otherwise use a java applet
How would I go about taking a picture from a video capture card or webcam? Should I use flash to do this? I want to submit the picture via a php form and upload it to my webserver and place a link to it in my MySQL database. Is there a flash app already built that I can use to perform this?
try this:
http://code.google.com/p/jpegcam/
I wud like to use file upload(ajax/javascript with php) in my form that has other controls also.
when i uploaded an img it displays on the same form with delete option.
if i click on submit it goes into folder as well as database &
if i click on delete it deletes an img....
anybody can help me?pls
u knw gmail file upload exact like that
It boils down to "Don't use XHR. Do use Flash or iframes". There are libraries that will do the heavy lifting for you.
Just use jQuery ajax upload plugin http://valums.com/ajax-upload/. It is actually not ajax, it's invisible iframe, but result is almost same.
For server-side you can use php with gd-library and some simple MySQL queries.