I wish to pass image in get url in php. Like how id is passed
For eg. http://myurl.com?id=1 . Similarly I wish to pass an entire image instead of the id.
How do I do it?
actually i have made a web service in php, and want to test it in browser. The service also contains an image to be passed and saved in database n also on server. So how do i do this?
You can convert your image to base64 code, and then send the code via GET. There's an easy to use image to base64 code converter at http://webcodertools.com/imagetobase64converter
Related
I'm trying to hide my image url including dir path. I tried base64 but it always shows the same url, I need a different one everytime I hit refresh. I then tried to create a temporary one using tempnam, but it only adds some characters at the end of the link and don't change the dir path.
I also tried createimagefrompng but it gives me either my website with no picture, or just a picture of a white frame.
When my player goes on the page, the page generate a random number from 1 to 5 and letter A or B, go in folder "A" or "B" and search for the picture with the generated number in that folder.
The Problem is the picture url is images/A/1.png, I want it to be random so he can't use a script to refresh until he gets A/3.
And I want it to be different everytime because he could find A/3 embed url and use the script to find that embed url.
Thank you!
Jessie
Ok managed to finally make it work!
I'm using a mix of things I've already tried.
So first the base64encode was great, but it always had the same url which I didn't want.
So I searched on how create a new encoding that I could make random and found that code: https://gist.github.com/LogIN-/e451ab0e8738138bc60b
I then generate a random key and encode the image link using that random key.
I then call an php image using createimagefrompng and put the key and encoded image link in the php url (www.example.com/image.php?encoded=jsnda9d9832rm&key=emd39023)
And then in that php decode the url using the key and show the image ^^
Hope it can helps other, also if you see something I could change so my code will be lighter or have better performance please don't hesitate :)
I am trying to grab an image on my WebNative Xinet portal. When i use the method i am using right now: I get an image back, but i also get all the HTML with it to display the image. This is what i am using to grab the image right now:
GETIMAGE.php?type=small&path=/Images/myimage.png
This is kind of working. The issue with this is that it returns a complete HTML document with the image tags in it displaying the image.
How is it possible to get the raw image back with no HTML included? My main objective is to grab the image and encode it to base64 to be displayed in an e-mail.
That request should absolutely be giving you an HTTP response with an image payload.
I'm assuming you're using cURL to speak with Portal. Did you authenticate with server before making the GETIMAGE.php request? If so, are you including the session ID cookie in your GETIMAGE.php request?
EDIT: I saw your other post and it looks exactly like the auto-generated code Chrome shows in its DOM inspector. Are you sure you're getting HTML from that URL? I'm staring at the source and I can't find anywhere where it emits HTML.
I need to save a random image from website to my computer. I know how to save images with PHP (I use curl), but I can't properly save random (dynamic) images.
Let's say that website (somesite.com) has some text content and IMG tag which looks like <img src='somesite.com/image.php'> and displays a random image. If I use browser, I can simply right-click and select "Save Image", so the image that I see on the screen will be saved (and they both will be the same).
However, if I use curl to open somesite.com (because I need to grab image description as well) and then use curl again to open somesite.com/image.php, images will be different (because a random one is selected every time user requests image.php).
Put simply, if somesite.com has text "this is rose", image.php will display a rose, and everything will look fine on browser. But if I use curl to open site, it may have text "this is tulip" and when I request image.php to save that image, another image will be displayed. How do I get exactly the same image saved that is displayed when first request is sent?
I guess it should be cached somewhere, or what?
It's not cached anywhere you can most likely reach. The best way to do this would be to put the randomizing into the calling file, so something like <img src='somesite.com/image.php?data=<?php echo $someRandomValue; ?>'>. You'd then use this data parameter to generate the same image every time this image is requested with that same data parameter. Of course: if there are multiple variables that affect the image, you can add more parameters to the url or simply put them in an array and pass it along base64 encoded.
I want a help,I created a facebook app using php gd.The program is when user open the app a image will appear.The image contains the username of the user,the profile pic and random generated nick name.Iam saving the output image to the server as resized.jpg and post that image to the users wall using facebook graph.
The problem is when 2 users use the app at same time,the output varies.
How to generate image to each user without saving it to the server and post to facebook.
now iam using html img tag to display the image in app..
Answer is quite simple: your image file name must have different names per user. If you have user id in $uid variable,why don't you save target file as:
imagejpeg( $rImg, "resized".$uid.".jpg" );
This way you'll have different images per user.
Rather than saving the file to your server as "resized.jpg", what you want to do is to output the generated image directly to the user. From http://php.net/manual/en/function.imagejpeg.php it says to set filename to NULL, which causes the output to be sent to the user instead of to a file. Note: you may also need to set the correct Content-Type using the header function.
This method is an alternative to Tomasz's. With his method, each image is cached on your server. With mine, the image is generated each time the page is requested. Here is an example showing the difference:
<img src="http://example.com/resized1234.jpg"> #1234 is the user's id
<img src="http://example.com/generate-image.php?uid=1234">
In your case, you said you are posting the image directly to Facebook, so I would advise my method, as Facebook will store its own copy of the image if you post it on their site, and won't need to be cached. Also, you won't have a other user's images piling up on your site.
Let me know if you need me to clarify anything in my answer!
Ok, so I have a php api on one server used for uploading images, and I want it to redirect to another server while passing along the $_FILES data. I tried using the header() method, but it seems $_FILES gets lost in the process. What would be the most straightforward solution?
Thanks!
best idea would be to
save image
send request to another server with link to current image
get image from target server
proccess image on target server
delete image from source server
It's nothing hard.
You can't redirect using existing POST (or FILES) data, only GET (the URL query string).
You can either save that data in session / disk / DB and reference it via a GET parameter.
You could serialize the $_FILES array, and pass it as a URL argument. But it wouldn't do you much good. The actual uploaded file's contents aren't included in this array; just the name and some metadata. Plus the file will be deleted at the end of the original script.