I am trying to make an ecommerce website. Vendors can add images and details of their products. On selecting an image it will upload to remote machine successfully by using ajax and js. When the vendor submitting the details about the product it will added to the database after compressing of the uploaded image. Backend is completely with php & mysql. When submitting the the product details it showing an error 500. Is it because of file permissions or any other error?
Related
On my website I let registered members create multiple profiles, each of these with their own avatar picture.
On the Create Profile page, I have this input to submit the avatar...
... and get it displayed on the Profile page:
How can I recreate the same, uploading one more picture from Create Profile and display it on Profile page?
I know where the source files for each page are located, but unfortunately I’m unable to recreate it..
Thanks.
You need a 3 step process to upload the image file, store it and send it to the front-end users.
If your app is an SPA and you don't want to reload the page in the user's browser, you'll need a JS process to read the file from a file button and send it to your server (through AJAX as a FormData object for example)
Then your server should be able to handle the formdata object request and read file content from it. Once done, you have to save it in a secure server-side location.
Finally (again in case of an SPA) your server should be able to answer the picture data when the client asks it
The server should be able to give the avatar's URL when asked by the client (with a Restful API for example)
The server should be able to give access to the image when the client uses the image's url
I have a form in which I want to upload an excel sheet, when I choose the file I want to show the number of records of the file, before uploading the excel file. Is it possible by ajax?
Unfortunately, Se0ng11 is right. On client side, there is no way to parse the file you are uploading. It is security rule and there is no way to get around. File selected in form you can just send to backend. Nothing more.
I'm trying to build a service into my website to allow uploads to be saved to owncloud and then displayed.
As per this: Uploading files to an ownCloud server programatically
I was able to setup postman to upload files and successfully save to serve. Now how do I display those files or do a getrequest to display an image on my website?
I found the get command. You need to make sure you have the authorization header as in postman for example.
You could do a get call
<baseurl>/owncloud/remote.php/<user>/<folder>/<pathtofile>
if you click on authorization select normal then put in your credentials it will generate a token key for you, this should be a separate call itself to generate a unique one each time.
You can also create folders to upload to using the MKCOL request. I had to export my postman and edit the export to have the MKCOL request b/c they are not built in.
<baseurl>/owncloud/remote.php/<user>/<foldertocreate>
It's surprisingly hard to find a definitive answer to this, I'm 95% sure what I'm trying to achieve is impossible, but here goes:
Front:
I have a multipart/form-data upload form. A user selects a file, but has to be logged in before he can post the form. The user can log in via Twitter. If he does so after selecting a file, due to the redirect to/from Twitter, the file input will be empty.
Back:
I have a PHP script using the $_FILES array to move the uploaded file to its final destination. (A solution to my problem would be to save the file to a temporary folder before redirecting to Twitter, but I currently can't set that up).
Problem:
I can store the selected file in localStorage using the FileSystem API (at least in modern browsers). But I obviously can't put that back in the input element. Now I'm at a loss: is there any way to get that file from my localStorage into the PHP $_FILES array?
Login to Twitter via ajax. This way you will stay on your current page and the file input will stay filled.
I am working on a project where I need to upload an image to google cloud services..
The question is what are the steps that you take to upload an image to google cloud services in the web browser, I would prefer to upload it directly to google cloud services on the client side rather than uploading to my webserver and then uploading to google. Seems like that would take too many steps.
A little background is that this will take place in a mobile web browser..
Steps:
- A user will take a photo after clicking a button that launches their camera
- They will click save and the image will be uploaded directly to google cloud services, which will return a given id for that image to be stored in a table
I have read google cloud services documentation, yet primarily the information I found was related directly to android/ios for storage. I understand that you cannot upload an image using ajax, yet you can do it within an iframe. Is it possible to get the image binary data and convert it to base64 and then upload that string to google cloud services in order to store the data?
TLDR:
- What are the steps in order to upload an image to google cloud services?
In google App engine it is possible to upload image by converting to base64 but you will need to convert it again into binary blob type from base64 to store it.
It is possible to upload a image directly to google app engine just by using a single html form having <input file="" name="fileupload"/> on client side. Endpoint will be the servlet address on google appengine which handle this form request.
On the server side toy just need to get parameters of submitted form. Assign parameter named fileupload into blob type and then save using entity or in resource.
update: Submitting a from is possible through ajax without reloading but simple jquery/javascript don't support form submission which has input tag of file type therefore, a jquery plugin used to do this :
Ex:
$(function() {
$('#submitForm').ajaxForm(function(result) {
// Do some DOM operation like hiding loader
}).submit();
});