Vimeo API upload video and bypass temp file on the server - php

I'm using the Vimeo API to create an upload interface on my website. However, the standard example here https://developer.vimeo.com/api/guides/videos/upload requires the file to be uploaded via a temp file on my server. Unfortunately, the size of file I can upload is limited by the php ini settings to 20mb (editing the php ini file is not permitted with my hosting package).
After searching on here, all the examples I can find appear to use the same method and require $_FILES['fileToUpload']['tmp_name'] - tmp_name being the temporary file created on my server when uploading - which fails if the file is larger than 20mb.
Is it even possible to upload directly from client (desktop or mobile device) to vimeo's server? If it is, can someone point me in the direction of an example or guides?

Related

php file_exists on FTP Uploading file [duplicate]

My application is keeping watch on a set of folders where users can upload files. When a file upload is finished I have to apply a treatment, but I don't know how to detect that a file has not finish to upload.
Any way to detect if a file is not released yet by the FTP server?
There's no generic solution to this problem.
Some FTP servers lock the file being uploaded, preventing you from accessing it, while the file is still being uploaded. For example IIS FTP server does that. Most other FTP servers do not. See my answer at Prevent file from being accessed as it's being uploaded.
There are some common workarounds to the problem (originally posted in SFTP file lock mechanism, but relevant for the FTP too):
You can have the client upload a "done" file once the upload finishes. Make your automated system wait for the "done" file to appear.
You can have a dedicated "upload" folder and have the client (atomically) move the uploaded file to a "done" folder. Make your automated system look to the "done" folder only.
Have a file naming convention for files being uploaded (".filepart") and have the client (atomically) rename the file after upload to its final name. Make your automated system ignore the ".filepart" files.
See (my) article Locking files while uploading / Upload to temporary file name for an example of implementing this approach.
Also, some FTP servers have this functionality built-in. For example ProFTPD with its HiddenStores directive.
A gross hack is to periodically check for file attributes (size and time) and consider the upload finished, if the attributes have not changed for some time interval.
You can also make use of the fact that some file formats have clear end-of-the-file marker (like XML or ZIP). So you know, that the file is incomplete.
Some FTP servers allow you to configure a hook to be called, when an upload is finished. You can make use of that. For example ProFTPD has a mod_exec module (see the ExecOnCommand directive).
I use ftputil to implement this work-around:
connect to ftp server
list all files of the directory
call stat() on each file
wait N seconds
For each file: call stat() again. If result is different, then skip this file, since it was modified during the last seconds.
If stat() result is not different, then download the file.
This whole ftp-fetching is old and obsolete technology. I hope that the customer will use a modern http API the next time :-)
If you are reading files of particular extensions, then use WINSCP for File Transfer. It will create a temporary file with extension .filepart and it will turn to the actual file extension once it fully transfer the file.
I hope, it will help someone.
This is a classic problem with FTP transfers. The only mostly reliable method I've found is to send a file, then send a second short "marker" file just to tell the recipient the transfer of the first is complete. You can use a file naming convention and just check for existence of the second file.
You might get fancy and make the content of the second file a checksum of the first file. Then you could verify the first file. (You don't have the problem with the second file because you just wait until file size = checksum size).
And of course this only works if you can get the sender to send a second file.

social.png upload viruses as images in php

I know for the fact that there is trojan or malware in php which represents itself as an image. And I also know that to filter out the file upload we use extensions such as .txt or .png.
Is there a way to scan the files manually when they are being uploaded into the server using server built-in antivirus or the server doing this kind of tasks automatically for us? ( I mean particularly in cpanel )
thanks
If you are worried about code being uploaded to your server in the form of an image, simply re-encode the image upon upload. A file containing code with an image extension will throw an error when the encoder tries to process it.

Dropbox api - Can you get a hook to a file in dropbox? - PHP

I am investigating dropbox possibilities for integration with another api.
Can you get a hook to a file in dropbox.. for example - a url to open up and resave the file with new content.
Can you also create files using the dropbox api if permission has previously been granted? Maybe .txt or .xls files etc.
I believe that dropbox uses a local folder to store files, then some sort of background daemon to monitor said folder for changes. If this is the case, you can simply make changes to files in that folder and the rest should be automatic.
Please correct me if I'm wrong.

FTP upload through a PHP page

I have an administration page on a website, from which the admin AND THE ADMIN ONLY can manage users and upload files from local hard drive for these users to download. The admin uses this page to upload files for his customers or to store files he needs when he has no memory device available. The files size may vary from a few Kb to a lot of hundreds megabytes.
The ideal solution:
An HTML form through which the admin can choose a file and upload it, to download it back later. This can be done in PHP.
The problems:
I cannot set the "max_file_size" variable in php.ini because the hosting doesn't let me
I tried FTP upload (PHP function ftp_put()) but it requires me to upload the file with a POST anyway
Even though it's completely wrong, I used a input="text" instead of input="file" to write the whole file path and upload it, but I get the following error:
Warning: ftp_put(insert_local_file_path_here)[function.ftp-put]:
failed to open stream: No such file or directory in path_to_php_script.php on line 70
The insane thing is... on Monday this was working, and now it's not. No changes were done and the file is the same.
My only conclusion:
With my little knowledge, all I could think of is a Java applet which does the required tasks that opens on the administration page. But if someone disables javascript/has no Java installed, the thing will not work, so it's not 100% bulletproof.
Have you got any ideas how to overcome such an issue?
If you need to upload big files you must use ftp protocol to make it. You can't upload big files if you don't have acces to php.ini. Sad but true

Web Development: How can I allow a user to upload files directly to my CDN (Cachefly)?

I have a PHP web-application that allows users to upload images to my web site. I'm doing this using a simply HTML <form enctype="multipart/form-data">
However, instead of having those images uploaded to my web server - I would to have those images uploaded directly to my CDN (Cachefly - which is another server).
Is this possible ... to have a web-application allow a user to upload images directly to another server?
In case it helps, here's my PHP code:
$target_path = "/home/www/example.com/uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
// file has been uploaded **LOCALLY**
// HOWEVER, instead of it being upload locally, I would like the file
// to be directly uploaded to the CDN ('other' server)
...
} else{
// error: file did not get uploaded correctly
....
}
i think in case of a CDN ... u will first have to receive files on ur server and then using the CDN API upload to their 'bucket'. i dont think u can upload directly to a CDN unless there is a way to map it as a directory on ur server.
Moving / Uploading a file to a service or for you non-direct-accesable server is usually done by using the provider's API
Moving / Uploading a file to a server 'owned' by yourself can be done by using PHP + FTP extensions (for more information: pear.php.net or pecl.php.net)
Moving / Uploading a file to a server 'owned' by yourself and being one of many in a cluster is usually done by uploading the file temporary on 1 server and afterwards a .sh, .bash or whatever is called which activates further transfer processes to another server.
I don't think it's possible to directly upload to another server, but I could be wrong. I had a similar problem, and I used PHP's FTP capabilities (http://us3.php.net/manual/en/book.ftp.php). I still used my server as a middle-man, meaning I uploaded the files to my server, then FTP transferred them to the target server, and then deleted the file from my server.
You could recieve it on your webserver and then transfer it to the CDN via fileshare or FTP.
If the CDN is web-facing, you could re-direct the request to that server and send control back to your webserver form once the file is uploaded. It's probably better to do the file transfer in the back end though and keep the user connected to the web server.
Sure.
Somewhere in your code there is a "$target_directory" variable that needs to be set. It won't be called that, but depeding on how your function is set up it needs to be there -somewhere-. Just use an absolute path for the directory you want the files to land in. Also, make sure that directory is CHMOD'd to 777 so it can be written into.
Post your code and I can help more.
Yes amazon web services already allows you to upload to amazon S3 directly from the user's browser:
Documentation: http://doc.s3.amazonaws.com/proposals/post.html
Additionally that S3 bucket can be exposed via the amazon CDN (or any other cdn that can point to a customer's origin server)

Categories