Upload file as url parameter in php - php

I am trying to make a Telegram Bot and it needs to upload a certificate file to it's server (see enter link description here).
The target url is something like this:
"https://api.telegram.org/bot/setWebhook?url=somewhere/on/the.web&certificate='certFile.cer'"
I need to specify two parameters within a php file.
1- the url
2- the file which should be upload.
now as I am new in php I don't know how to send file as a parameter.
I tried to do it by a html form like this:
<form action="https://api.telegram.org/bot########:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/setWebhook" method="post" enctype="multipart/form-data">
<input type="url" name="url" value="https://XXXXX.com/send.php"/><br/>
<input type="file" name="certificate" /><br/>
<input type="submit" name="btn" /><br/>
</form>
But it doesn't work.
Any advice will be appreciated.

Related

Need guidance with html form file upload using Dotster

First off, I have no experience with PHP. I'm setting up a form on a site that is hosted on Dotster using their link. This works to send an email with all of the info, but the file that is selected for upload disappears. Does not end up on the server, does not attach to the email. Are there any ways to determine or control where the file goes using their script?
<form method="post" action="https://www1.dotster.com/scripts/formemail.html" enctype="multipart/form-data">
<input type="hidden" name="my_email" value="flyboyjr#gmail.com">
<input type="hidden" name="subject" value="Nomination Form">
<h1>Nominee Information</h1>
<label for="photo">Please upload a photo of the nominee in uniform or sports attire appropriate with
their
nomination. Please make sure it includes a clear view of their face.</label><br><br>
<input type="file" id="photo" name="photo" required>

How to pass a file through two forms

I have the following form that allows uploading a file:
<form id="form1" name="form1" method="post" action="page1.php" enctype="multipart/form-data">>
CSV list: <input type="file" name="file" id="file">
<input type="submit">
</form>
When I go to my action/submit page I can retrieve the file and the temp location of the file, but I need to send it through again to a new page, so I do the following:
<form method="post" action="page2.php" name="details" >
<input type="hidden" id="type" name="type" value="1">
<input type="hidden" id="filename" name="filename" value="<? echo $_FILES["file"]["tmp_name"]; ?>">
<input type="submit" value="Insert Into Database">
</form>
This doesn't work because the temp file is already gone.... how can I pass the file through?
I think you want to rethink how you are getting this data. If it was me, I would want to have the first form upload the file to a temporary directory and pass the path to the file through a $_REQUEST. Then use a hidden input field pass the file path name through PHP and if they confirm their selection on the second form, do whatever you want with the file using the file's path. This means you don't have to upload two files(not efficient) and you can pass the data onto the second form.

Automatically choose file and upload to desired server. How to do this?

Hello I needed code for automatically chose file and upload it to desired link. How to do that?
html code:
<html>
<head><title>Uploading</title></head>
<body>
<form method="post" enctype="multipart/form-data" action="uploadFile.php">
<input type="file" name="file" id="file">
<input type="submit" value="Submit">
</form>
</body>
</html>]
In above code at this line
<input type="file" name="file" id="file">
this path is fixed and can't be changed as user tries. so when user click on "Submit" button the file has to upload.
How to do this?
TL;DR: What you are trying to do is absolutely impossible - for a good reason.
If this was possible, you could create a hidden upload field pointing to a file containing valuable data (e.g. the browser's cookie database) and submit the form using JavaScript (or make the user submit it without knowing about that upload) and copy any file the user has access to.

Youtube API upload from website WITH diff. TITLES

I am using this code to make a upload-form for my website.
Youtubeuploader
It works perfect, but I got ONE problem.
I want a form to define the title.
Right now, all the videos are given the title "Example"
I want the user to write their own title for their video.
I've tried making a input with id and name "title", and tried to use $_POST['title'], but it didn't work. The video didn't even upload.
Anyone knows how to do this?
I've looked at all the YouTube Data API code and tried everything.
Thanks.
Given the link you posted, you have to give $youtube_video_title the value from your form.
I mean like this (not secure, always sanitize and filter):
$youtube_video_title = $_POST['title'];
UPDATE :
try to replace the form code with this one
<form action="<?php echo($response->url); ?>?nexturl=<?php echo(urlencode($nexturl)); ?>" method="post" enctype="multipart/form-data" onsubmit="return checkForFile();">
Title : <input id="title" type="text" name="title"/>
<input id="file" type="file" name="file"/>
<div id="errMsg" style="display:none;color:red">
You need to specify a file.
</div>
<input type="hidden" name="token" value="<?php echo($response->token); ?>"/>
<input type="submit" value="go" />
</form>

Get remote file path location

I am working with PHP and would like to get a remote file path location so that I can read file contents.
I would like the user to direct to a particular file, which can be located anywhere in the computer, so that it can be processed by the script.
Thanks
You can offer a user the ability to locate a file on their local computer and submit it to you via a web form, like..
<form id="myForm" enctype="multipart/form-data" action="/formHandler.php" method="post" >
<label for="fileUpload">File to Upload:</label>
<input name="fileUpload" id="fileUpload" type="file" /><br />
<input name="submit" id="submit" type="submit" value="Upload Now"></form>
Then you can process it on your side with PHP, or whatever you have on the server end. Since PHP is one of your tags, you can learn more on how to access, and work with, on the server end from the PHP reference site:
http://www.php.net/manual/en/features.file-upload.post-method.php
I hope I understood your question correctly..

Categories