This is my code to save a file in laravel storage folder and the file url in mysql database.
$summary_attachment = $request->file('claimSummary');
$new_summary_attachment = time().$summary_attachment->getClientOriginalName();
$summary_attachment_path = $request->file('claimSummary')->storeAs('uploads', $new_summary_attachment);
$attachment_path = Storage::url($summary_attachment_path);
$individual_application->summary_attachment = $attachment_path;
$individual_application->save();
Anf this is my view file where I am retrieving the url of the file and giving the url as a value to href in anchor tag.
Claim Summary
But nothing happens when I click the link. When I hover over the link, the url is displayed in the bottom. But it doesn't show any errors. Just nothing happens when I click the link. When I right click, use copy url and paste it in new tab, the file is downloading. Just nothing happens when I click the link. Could somebody please mention what am I missing here. Please help.
Related
sending page
has a link like so,
<a href="http://someurl.org/share?id=<?php echo $ftime;?>" >link to share</a>
which produces the correct url form of the GET method by inserting the filemtime() integer that i want to show on the share page, it looks like this on the end of the url
...share?id=1588888386
on the share page
i'm using $_GET['id'] to define a variable
$id = $_GET['id'];
and then inserting that variable into the src of the image file, like so
<img src="test<?php echo $id;?>.jpg">
which correctly resolves to
test1588888386.jpg
but the image is broken and "Could not load image" according to Firefox even tho that file exists right along side the test.jpg file on the host server... and the base image loads just fine if the 'id' string is NULL.
originally tried using $_GET['id'] directly in the src without going the $id route gives the same results.
i'm at a loss, the only weird clue is FF warning me about "mixed content" with a greyed out padlock.
am i violating some taboo by doing this?
all i want to do is share the version of test.jpg that has that 10digit dynamic number in the file name (the number is extracted from the timestamp when the file is first created).
for now, i'm just manually renaming the file on server, but will eventually use php to copy the test.jpg file and rename it dynamically to add the timestamp, so the test.jpg file can be overwritten the next time it's created by user activity.
I have an add form, where users can add an image, once they click submit I want the image to be saved into a certain folder located called Event_images (which I use to display the image on another page where I display the image along with other details they inputted. But once I submit the form, the image goes to the MYSQL database, but isn't in the folder where I direct it to. My code and a screenshot are provided. I want the image to be displayed in the Event_images folder I have created. Thank you in advance.
<?php
$event_img = $_FILES['event_img']['name'];
$tempimage = $_FILES['event_img']['tempname'];
move_uploaded_file($tempimage,"Event_images/$event_img");
?>
The screenshot I have provided is what happens when I try to display the information (because nothing is in the folder which I direct to)
['tempname'] isn't an index of $_FILES. See here.
Use $tempimage = $_FILES['event_img']['tmp_name']; instead. I tested locally and it worked fine. If you're using PHP 7 you may need to use { } around $event_img when you move the file so it'll process that variable.
Does this work?
$event_img = rand(1000,100000)."-".$_FILES['event_img']['name'];
$tempimage = $_FILES['event_img']['temp_name'];
$folder="Event_images/";
move_uploaded_file($file_loc,$folder.$event_img);
I am facing one problem i want to save data after downloading an image. My image has been successfully downloaded after that i want to maintain the history of downloads.Here is my Function:-
enter code here
public function UserImageDownlaod($userid=null,$imageid=null){
$imagedata = DB::table('alt_images')->where('id',$imageid)->first();
$imagedata = json_decode(json_encode($imagedata),true);
$destination = 'images/ContributorImages'.'/';
$pathToFile = $destination.$imagedata['img'];
return response()->download($pathToFile);
//Now i want to save the history of downloaded images
$history= new DownloadHistory;
$history->user_id = Auth::user()->id;
$history->alt_image_id = $imageid;
$history->save();
}
Now you can see after this return response()->download($pathToFile) line i want to save the history data. I want when User click on OK button then data will saved on history table. Can anyone help me.
The popup you showed us is from the browser. At the point, you see this popup, the browser might already started to download the file in the background. As this is part of your browser and you dont have any callback about pressing ok/cancel, there is no direct way to determine, what the user did.
A simple workaround would be, to show the user an alert box in javascript and ask, if he really wants to download the file.
Download
So i have this one small thing im doing, and the thing is: It generates QRcodes using the google qrcode api. Id like to download the generated qr code with the press of a button into a /img folder i have inside the folder my php file is located at, and id need it to save with a numerical number which is the button's id. (it has like 120 buttons and each one has a 0-120 id, id like to save the qrcode that belongs to the button 10 with a name like 10.png) any ideas on how to do so?
__
Little edit: as Man Manam pointed out my question is: I have the image link, i want to save it in my server. Sorry for the confusion.
As you're using Google for creating the QR code, I assume you have a code like this somewhere:
$ga = new \Google\Authenticator\GoogleAuthenticator();
$qr_link = $ga->getUrl($username, $_SERVER['HTTP_HOST'], $secret);
// then you'd display that code with <img src="$qr_link">
What you need to do is to simply download that QR code instead of showing in browser. You can use curl for this or, even simpler, just fopen/file_get_contents if allow_url_fopen is set to ON in php.ini
$image_bin = file_get_contents($qr_link);
file_put_contents($target_file_on_filesyste, $image_bin);
I currently have a problem to open a .ppt/.pptx file inside a webpage. I currently have all "uploaded" file in a folder and am able to open .html/.txt files in that folder, but not .ppt/.pptx. Whenever I try, a new window pops up and Windows Uploader starts to run.
<?php
$target_dir = "C:\Apache\htdocs\upload\\";
$target_file = $_FILES['file']['name'];
?>
<iframe src = "upload/"<?php echo $target_file; ?>" name = "iframe_s" id = "download" style = "display:none"></iframe>
Click here to view files
In the above code, I try to list all files in the folder, and the goal is a user can click on one of the file, then the file will open inside the webpage. The main problem I have right now is to have the program each individually attach different .ppt url to different files.
Thank you in advance!
For your question "How to upload to Google Docs".
My first Answer:Why don't you search properly???
If you still don't find it. Then, (taken from here)
You'd use the Google Documents API to upload them using a simple HTTP POST with the data. Here's an explanation how to upload and convert documents: http://code.google.com/apis/documents/docs/3.0/developers_guide_protocol.html#UploadingDocs
The link will provide you will examples and all you need to do what you were asking for.
To be more precise this is what you are looking for if you want to upload pdf's: http://code.google.com/apis/documents/docs/3.0/developers_guide_protocol.html#ResumableUploadPUT
Python Google Documents API guide
PHP Google Documents API guide