I wanna make my own little renderfarm-backend building on php and mysql. I have a huge plan for doing everything but there is one problem. How can I upload an image without a form?
Three alternatives:
you make exactly the POST request a browser would do when submitting an upload form, you do not need the form for that. It is a simple http POST. You can find countless examples for that here on SO or on google.
take a look at webdav, an http extension that allows flexible file access via http. Might make sense if you want to integrate your uploading into something like a local file manager or the like.
you use a file centered protocol for uploading, so implement the upload separate from the php stuff. sftp comes to mind here, but obviously you need to setup a separate server for that and map the file system locations as required. Also you have to take care of the file permissions.
Related
I'm stuck wondering what the best solution is to handling large file uploads and sending them to a third-party API. Any pointers on what would be a good solution would be very welcome. Thank you in advance.
The end goal is to send video files to this API - https://docs.bunny.net/reference/manage-videos#video_uploadvideo. The complication is that the files are often large - up to 5GB in size.
I have an existing website built in PHP7 that runs on a LAMP setup on Amazon Lightsail and I want to add a feature for users to upload video files.
Currently I'm uploading the files directly to Amazon S3 using a pre-signed URL. This part is working fine.
But I need to send the files to the API mentioned above. This is where I get stuck!
I think there's two options to explore - (1) find a way to upload directly to the API and skip the S3 upload or (2) continue with uploading to S3 first and then transfer to the API. But I'm not sure if option 1 is even possible or how to do option 2!
With option 1, I'm wondering if there's a way to upload the files from the users directly to the API. If I do this using the regular HTML form upload, then the files are stored temporarily on my server before I can use cURL through PHP to transfer them to the API. This is really time consuming and feels very inefficient. But I don't know how else to send the files to the API without them first being on my server. Maybe there's an option here that I don't know about!
With option 2, I can already upload large files directly to S3 with pre-signed URLs and this process seems to run fine. But I don't know how I would then send the file from S3 to the API. I can use an S3 trigger on new files. But when I looked at Lambda, they have a tiny file size limit. Because my site is hosted on Lightsail, I noticed they have a container option. But I don't know if that can be used for this purpose and if so, how.
Basically, I'm not sure what solution is best, nor how to proceed with that. And maybe there's an option 3 that I'm not aware of!
I would welcome your input.
Many thanks in advance.
I am making a form where the users should be able to attach files that can be relevant to the form data.
I'm facing the problem that I can't upload more than 2MB of files in a POST request since that's the default upload limit with post, and I don't have access to change that limit since the server is hosted by a service provider that just doesn't allow that.
I know how to upload via FTP with php, but that is all server-side code, and if I'm not mistaken, that will not work with uploading files from client-side, eg: a client browses for a file, then submits.
While looking for solutions on SO and elsewhere, I came across endless terms like chunking, JSP, Java applets, silverlight, etc... To the point that I am lost. I know I can't use Java applet since it will not work on mobile phones.
To make it clear, Im asking for any solution where a client can browse for a file and upload it with (or before) a php form, that can still work on mobile (if possible).
Can anyone please point me in the right direction?
$aConfig['upload_path'] = 'path';//path where to upload file
$aConfig['allowed_types'] = 'mime type';// the file format which has to accepted
$aConfig['file_name'] = strtolower(date('Y').$_FILES['file']['name']);
$this->upload->initialize($aConfig);
$this->upload->do_upload('pdf');
Dont define any file limit like this
I am trying to develop a RESTFUL API call in PHP , where someone will send me a file through the URL to upload
something like:
script.php?file_name=text.txt
is there away I can take text.txt and upload it in PHP?
To clarify:
lets put it this way , what are the ways that a end user could send a file to a PHP program?
The problem with this is that the REST server is not aware of the end user's machine in any way. So, say for instance that your end user is at yoursite.com/upload where they fill out a form with the upload credentials which posts to api.yoursite.com/uploads/do or whatever. As far as the api is concerned, yoursite.com is making the request, not the end user.
So, no. In my opinion there is no safe way to do this. The best alternative would be to upload the file and then HTTP POST the contents to the rest server. That can be tricky if the file is much larger than a few kilobytes, and you would want to do all sorts of security checking before writing the file to the server. The other option would be to use yoursite.com to upload the file to a temporary location and then send some information to the rest server with details on out to CURL the file contents from the first server. Also, can be insecure.
What problem are you trying to solve? What language framework? Can you give more details please?
I'm currently working on a Django application using AngularJS for the frontend part.
I want for the moment to upload some images on the server and get as callback a list with the paths of the uploaded files. I want to send afterwards to the API (I am using Tastypie framework) as a POST request the callback and insert it into the database in a specific field. My issue is that I don't know how to approach the images upload (I should use PHP?) part and most important how to receive the callback? I hope that I explain clear enough. :D
Documentation for uploading files in django: https://docs.djangoproject.com/en/dev/topics/http/file-uploads/
HTML only allows to upload one file per upload-controller. To upload multiple files either the user can create a zip file (or similar), upload that and on the server side you extract it into multiple files. Or you have to use a flash component. There are lots of these available, for example http://developer.yahoo.com/yui/uploader/
Ok. I am a bit of a new developer and haven't done much work with networking (in general, not specifically obj-c). Basically, I need to record a file (I have code to do this), then upload it to a server. I've looked at code to upload to servers and it seems that all I need from the server side of things is a html upload page with a php script, which I have. Another option would be ftp/sftp, although this would be harder to implement. The problem is I need to have authentication for the upload, and preferably have a secure (https) upload, with a username and password. I cannot figure out how to do this. I would also need the server to send back a response to the app.
Also, are their any frameworks to make it easier to upload files? I know there was asihttprequest, but that was discontinued...
What would I need to make the server do to have authentication and authenticated uploads, and be able to return data back to the app? Sorry for such a n00by question, but if you could help that would be great.
Thanks
Check out AFNetworking. I really enjoy doing file downloads and uploads using AFNetworking. The FAQ even gives an example on how to upload a file and download a file. All you need server side is a PHP script to handle a POST file upload.