How to get actual image from local path in PHP? - php

Disclaimer - Thanks for coming to this question! I would just like to say that I am an absolute beginner to PHP. Thanks!
Hi! I am working on a project (more specifically, a mobile-only App), in which I need to do the following things -
The user would give me his/her phone's path to the image, which is stored in his mobile.
Through API, I would send the path to my website's PHP file, and the PHP would capture the image from the path.
After displaying the image, the code would compress it with very high compression, and display the temporarily store the image.
Then I would upload the image to AWS S3 media database(maybe with PHP SDK?), and obtain the image's link.
So that's my plan, is it possible to do? And what are the steps to do the 2nd & 3rd step - i.e. catching the image from the phone's local path, and compressing it?
Any help is appreciated :)
Thanks a lot!

There is no possibility for you to remotely access any known mobile operating system's storage.
You want to upload a photo and process it - just do it! You can simply send the photo through your API to the PHP server, and it would receive it as it would receive any other file, e.g. from a website form.
Then, you use some tool like Imagick to edit the photo.
You return thumbnail to the user within the response of your API.
Yet simpler, isn't it?

Related

Catch forced download using CURL PHP

So apparently Facebook recently (I think it is as of today) started to force download a profile picture when looking it up using the following url: graph.facebook.com/{FBID}/picture?type=large. Before it just showed it in the browser. This breaks some of the behavior of my app. I.e. all of the profile pictures are not loading anymore.
So I thought I might just run over the complete database; downloading all the pictures using PHP and uploading them to my server. But I don't understand how to do this. I do understand how to download and upload a 'normal' .jpg or .png file or whatever using Curl in PHP. But since this URL ends up downloading the picture (check it for yourself using a random FBID with the above mentioned URL) I do not know how to 'catch' it - so to say - and upload it to my server.
I know it would be also possible to just use the User Picture Graph. But since the database is quite large, a part of the access_tokens expired. So I would end up with just a part of al the profile pictures.
Also, has someone any idea why Facebook changed this behavior (and not announced it in advance). I could not find it anywhere. Thanks

Prevent to download PDF, Video file using PHP

I am showing PDF, Video file preview in my web application, but i want to give only read access to users, no one can`t download PDF & video files, I want to prevent users, how can we prevent users to download it using PHP ? only they can view, please share you ideas as soon as.
Thanks
Any content that is shown on the client's side, technically speaking, already downloaded to the user's machine. If the user is seeing the PDF file - it's already been downloaded.
For video: it's not that straightforward, you can organize a streaming of the video. It'll be fairly more complex for the user to download it as one file, but still, can be captured.

Adding image upload to html page (mysql backend)

Relatively new to web development here, but am trying to implement an image upload feature, the contents of which will be previewed to the person (administrator) uploading the image, and then stored in a database (and displayed to the end user on a different page).
I found a resource that uses a Imageshack API, and was a bit confused about what this is and how the person implemented the API to achieve the image upload. The code for this is here: http://www.sceditor.com/posts/how-to-upload-and-insert-an-image/
When I googled "Imageshack API," I kept running across something that said I need to request a key. What does this mean, and do I have to do it? Is this the easiest way to go about creating an image upload feature for my purposes?
Thank you all very much!
Imageshack API is for uploading image files to your account hosted at Imageshack.com. It seems that you want to upload image files to your own website and store such files on your own web servers (either in a cloud service such as AWS or your co-located/managed servers at some data centres). So, you probably do not want to use Imageshack.
As to how to upload image files using HTML & PHP, you may want to check out a short tutorial at:
www.w3schools.com/php/php_file_upload.asp
Also, by the way, storing image files into a database such as MySQL may not be a good idea -- image files should be stored as files. It is faster to access such image files on a web server than to access image contents stored in a database.

How to post images to users' wall (or in folders/albums) on Facebook (2013)

I am using Facebook's PHP SDK. I looked here (official documentation by Facebook) for help. It is not working for me because I am using images hosted externally but if I try to upload files hosted within my server then it works fine.
Is there any new way to do this. Please try to explain both (Posting to feed and to some folder/album). Sorry for this question but others here were of no help to me.
Please suggest any PHP editor that is compatible with Facebook's API. (Auto-completion etc.)
Stack is normally for solving small issues (think using = rather than > in a query) not a complete project.
Have you attempted writing this code yourself, if so what errors is it spitting out? rather than saying it doesn't work.
If the images are stored somewhere out there, you need to download them to your server and upload them to FB. You can't just tell FB an URL of an image, it's not working like this.
In order to upload fotos, you may use the "photo post" Method on the FB API. And it wants the binary data of the image. You may link an input and an output stream to that (what I would prefer using Java since no storage is needed).
Since your code is working with locally hosted images, just encapsulate that part and make the external image an internal one first.

How to upload to a static content server with php?

I am launching a web application soon that will be serving a fair amount of images so I'd like to have a main web server and a static content server and possibly a separate database server later on.
I'd like the user to:
login and be able to upload a photo
the photo is renamed a randrom string
the photo is processed into a thumbnail
the photo and thumbnail are stored into a filesystem on the static server.
the photo and thumbnail's directory and filename are stored in a mysql database
The problem is I don't know how to have the user instantly upload an image to a separate server.
I thought about using amazon s3, but you can't edit filenames before posting them. (through POST, I'd rather not use the REST api)
I could also use php's ftp function to upload to a separate server, but I'd like to dynamically create folders based on the properties of the image (so I don't have all the images in one big folder obviously), but I don't know how this would work if I used ftp...
Or I could save them locally and use a CDN, I'm not too familiar with CDN's so I don't know if using them this way would be appropriate or cost-effective.
What are my options here? I'd like the images to be available instantly (no cron jobs/queues)
Thanks.
You can create directories over FTP with PHP, so that should not be a showstopper.
I thought about using amazon s3, but you can't edit filenames before posting them. (through POST, I'd rather not use the REST api)
If you let your PHP server do the uploading to S3 via POST, you can name the files whatever you want. You should do that anyway, letting your users upload to S3 directly, without your PHP code inbetween, sounds like bad for security to me.

Categories