The file is small about 4 to 5Kb.
I am trying to upload a fillable pdf to an Apache server.
The pdf has a submit button which uploads the PDF to a Zend IndexController using
$request=$this->getRequest();
$tempFile=time().'.pdf';
file_put_contents("data/tmp/".$tempFile, $request->getContent());
I am now trying to do the same in Drupal 7 to no avail. $_POST and $_FILES are both empty.
If I use an HTML form the file will upload, however, I want the end user to click on the button within the form.
I also tried
file_put_contents("data/tmp/".$tempFile, "php://input");
Which created the PDF file on the server, but it unfortunately only contains the text "php://input".
Can someone please advise how to do this?
Dale's answer
file_put_contents("data/tmp/".$tempFile, file_get_contents("php://input"));
is correct
Related
I have an external resource for my images let's say https://api.domain.com/api/downloads/{file_id}. The file gets downloaded after I visit that page. In this case I want to know the mimetype of the file. file_get_contents() doesn't work because the file is downloaded after I visit the page.
This means that I get HTML as output when I dump the result of file_get_contents(). I don't have any hold on how images are served to my application. So I guess I have to find a solution for this problem.
Is there a way to get the mimetype of a file after the page is loaded and it downloaded the file? If something I just wrote is not clear enough please let me know then I try to explain it further. Thanks in advance.
Some more detailed information:
I am currently creating an EML export from data from an external API from Genesys. This is pure PHP and thus I can’t make use of any client-side code like Javascript. The inline images in the body don’t show on in the EML export email body. I think this is because Genesys saves those images somewhere on their side. The image is not directly available from the URL they gave to me, because when I visit that page the page downloads a file but it is not directly served on that page.
To show the images inside the email body I want to encode them to base64 and change the src of the image to the base64 encoded image. To do so I need to know the filetype which I can’t get as described above.
Did you try with the onload property on the <img /> tag ?
<img src="w3html.gif" onload="loadImage()" width="100" height="132">
<script>
function loadImage() {
alert("Image is loaded");
}
</script>
https://www.w3schools.com/tags/ev_onload.asp
You will need to use javascript as the image is on a remote server and loaded on client side
I am using a PHP script to generate FDF response and in that response the PDF template is supplied as a remote file "https://platweb-eur.qa.reachlocal.com/test/546_df50ab50418e1e925e81020815217649.pdf"
This is opening up the PDF template properly, but the fields are not getting populated.
While I am using local PDF template instead of file URL for the same pdf, fields's value were getting populated correctly.
So the issue is with remote file. Can anybody point me to what is going wrong here ?
I have created the elements in the form for an upload document but the form has other elements as well. Now I can't seem to find out a way to upload files because no matter what I do is says "File 'img_file' exceeds the defined ini size" even if I try to save only another field in the form.
$file = new \Zend_Form_Element_File('img_file');
$file->setLabel ( \Zend_Registry::get('config')->form->docFile )
->setRequired(false);
Also added ->setEnctype(\Zend_Form::ENCTYPE_MULTIPART); for the form
Can somebody help me with the controller since I'm using MVC?
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
I am looking for a ajax php uploader to uploads multiple files , i found some but unfortunately they did not work successfully with IE because IE 7 & 8 did not support
HTML5.
Uploadify & Plupload works fine with flash in IE but they did not return anything after uploading the file.In response i want the modified file name because before uploading a file i will modify the file name.
Any help or suggestion would be highly appriciated.
Thanks
Gaurav
Please refer this link for multiple file uploads using uploadify php - file uploads using uploadify
and in that link(in uploadify.php) replace the line
$fna = $_FILES['Filedata']['name'];
with
$fna = "your modified new filename";