Insert multiple files into mysql - pdf

I am trying to create a form whereby I can select multiple files (they will be pdfs) and insert the file and the file's name into the database.
Html form works beautifully:
<form action="" method="POST" enctype="multipart/form-data">
<input type="file" name="files[]" multiple/>
<input type="submit"/>
</form>
But I can't seem to make the php work with it:
if(isset($_POST['files[]'])){
$file_name = $_POST['files[]']['name'];
$file_size =$_POST['files[]']['size'];
$file_type=$_POST['files[]']['type'];}
$query="INSERT INTO upload_data (`FILE_NAME`,`FILE_SIZE`,`FILE_TYPE`) VALUES('$file_name','$file_size','$file_type'); ";
I also don't know how to insert the actual file, as opposed to just its properties. Any ideas?
UPDATE:
I got how to upload multiple files, and also multiple file names, but I cannot do both at the same time. Still need help. The code is:
<form action="" method="POST" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
<input type="file" name="files[]" multiple/>
<input type="submit"/>
</form>
if(isset($_FILES['files'])){
foreach ($_FILES['files']['name'] as $filename) {
$query=mysql_query("INSERT INTO practice (name) VALUES('$filename')", $c) or die("six");
}
}
and
if(isset($_FILES['files'])){
foreach ($_FILES['files'] as $file) {
$query=mysql_query("INSERT INTO practice (file) VALUES('$file')", $c) or die("six");
}
}

To get information about uploaded files, you need to use the $_FILES variable instead of the $_POST variable : http://www.php.net/manual/en/features.file-upload.post-method.php

Related

How to send a SPECIFIC file using a ASPUpload?

I want to send a time.txt by aspUpload (persist) without a form choice.
My code is:
<FORM METHOD="POST" ENCTYPE="multipart/form-data" ACTION="Up1.asp">
<INPUT multiple TYPE=FILE SIZE=50 NAME="FILE1" id=ARQ accept=".s3dx" onchange="ChangeFile();">
<INPUT TYPE=SUBMIT VALUE="Send Files" id=BT>
</FORM>
But i can to use: FILE = "time.txt"
is it possible?
I never change the file

Form action for controller in Prestashop

I'm searching the answer but without any luck. Perhaps I asked wrong question. I have a form in my cms page in PS 1.6. Code below:
<form method="post" action=""><input name="text1" type="text" /><br /> <input value="Check" onclick="getStatus()" type="button" /></form>
In \override\controllers\front\CmsController.php I have getStatus function. Which return "Hello world". Like You see "action" in form is empty. How to create link to this controller which is overrider ?
Kind regards
you can do like this.
In tpl
<form method="post" action="">
<input name="text1" type="text" /><br />
<input type="hidden" name="action" value="getStatus">
<input value="Check" type="submit" />
</form>
In Override controller
class CmsController extends CmsControllerCore
{
public function initContent(){
parent::initContent();
if(Tools::getValue('action') && Tools::getValue('action')=='getStatus'){
// Do your work What you want
echo "Hello world";
}
}
}
You can put: _PS_URI_?controller=cms&id_cms=1
Also can check dispatcher core and add your own rule or create a little module.
If is an override Controller u delete the file cache/class_index.php ?

php how to doing continuously processing

I have a form that will processing input.how to make it run continuos after i just click submit once?
I want to know the method.
say i have the code :
<form name="form1" action="" method="post">
<input type="text" name="tfcari" />
<input type="submit" name="btcari" />
</form>
<?php
if (isset($_POST['btcari'])) {
get(..);
?>
Thanks.

Google Custom Search with SEO URL

Well i have this search engine into my site
<form action="/apps/search/" name="g_search" id="cse-search-box" method="post">
<input type="hidden" name="cof" value="FORID:11;NB:1" />
<input type="hidden" name="ie" value="utf-8" />
<input type="text" autocomplete="off" name="google_seach" class="search-text" onfocus="searchtext('focus')" onblur="searchtext('blur')" />
<label style="color:#796b6b;float:left;padding:0;">|</label>
<input type="submit" style="float:right;margin-top:3px;cursor:pointer;width:16px;height:16px;background:url(/template/img/main/search-icon.jpg);border:none;" value="" alt="Αναζήτηση" title="Αναζήτηση" />
</form>
Now i want some code to results page.Somehow the post request readed from a file called search.php
This file have access to $_POST[] array..
The file initializes $selector variable (for template use).
What we want to echo into contentarea div must put into $body variable..
Any help?
<?php
$selector="search";
$body="<div id=\"cse-search-form\" style=\"width: 100%;\">Loading</div>";
?>
I have a similar issue, just use GCS code provide by Google as it easy, make sure in the option in GSE you select to visualize the search result on your page and not an Iframe

appcelerator post request. Send one variable few times in one request.

Hallo! I want to send variable few times(each time with different value) in one post query.
In HTML form it works and looks like:
<form method="POST" action="http://localhost/index.php">
<input type="hidden" name="line_item" value="value1">
<input type="hidden" name="line_item" value="value2">
<input type="hidden" name="line_item" value="value3">
</form>
But appcelerator sends only the last value in this code:
var httpClient = Titanium.Network.createHTTPClient();
var params = {
line_item:'value1',
line_item:'value2',
line_item:'value3',
};
httpClient.open('POST', 'http://localhost/index.php');
httpClient.send(params);
Can anyone help? Thanks.
Sorry, I forgot to mention that I don't have access to server and I need it solved in appcelerator.
if you use PHP as server platform, you can join POST-variables to array
<form method="POST" action="http://localhost/index.php">
<input type="hidden" name="line_item[]" value="value1">
<input type="hidden" name="line_item[]" value="value2">
<input type="hidden" name="line_item[]" value="value3">
</form>
and then process it like array in php:
if (is_array($_POST['line_item[]'])) {
$count = 0;
foreach($_POST['line_item[]'] as $line_item)
echo($line_item . " #" . $count++);
}
Solved...
var httpClient = Titanium.Network.createHTTPClient();
httpClient.open('POST', 'http://localhost/index.php');
httpClient.send("line_item=value1&line_item=value2&line_item=value3");