Hi I would like to point out before I get into this that I am a PHP newb, and I have been struggling for a while. I'm trying this new script, but I got an error every time I did upload file.
Warning: file_get_contents(): Filename cannot be empty in C:\Users\user\Desktop\xampp\htdocs\ubfm\d2.php on line 18 - <?php
-
// Check if a file has been uploaded
-
if(isset($_FILES['uploaded_file'])) {
-
// Make sure the file was sent without errors
-
{
-
// Connect to the database
-
$dbLink = new mysqli('localhost', 'root', '', 'upload');
-
if(mysqli_connect_error()) {
-
die("MySQL connection failed: ". mysqli_connect_error());
-
}
-
// Gather all required data
-
$name = &$_POST['name'];
-
$email = &$_POST['email'];
-
$subject = &$_POST['subject'];
-
$department = &$_POST['department'];
-
$message = &$_POST['message'];
-
$mime = $dbLink->real_escape_string($_FILES['uploaded_file']['type']);
-
$data = $dbLink->real_escape_string(file_get_contents($_FILES['uploaded_file']['tmp_name']));
-
$size = intval($_FILES['uploaded_file']['size']);
-
-
-
// Create the SQL query
-
$query = "
-
INSERT INTO `file`(Name,email,subject,department,message,mime,size,data,created)
-
VALUES('$name','$email','$subject','$department','$message','$mime',$size,'$data', NOW()
-
)";
-
-
// Execute the query
-
$result = $dbLink->query($query);
-
-
// Check if it was successfull
-
if($result) {
-
echo 'Success! Your file was successfully added!';
-
}
-
else {
-
echo 'Error! Failed to insert the file'
-
. "<pre>{$dbLink->error}</pre>";
-
}
-
}
-
-
-
}
-
else {
-
echo 'Error! A file was not sent!';
-
}
-
-
// Echo a link back to the main page
-
echo '<p>Click <a href="d1.php">here</a> to go back</p>';
-
?>
2 4768
Is your file input named uploaded_files?
Hi iam_clint,
Yes that my input name.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Auday Alwash |
last post by:
Hi,
A month ago, we were running out of disk space on a drive that stores
the data file for a SQL Server 7 database. So I added a new drive and
created a new data file on the primary filegroup...
|
by: Tjerk Wolterink |
last post by:
i have the following rule,
<xsl:template match="br">
<br/>
</xsl:template>
This should convert all <br/> to <br/>
but, my transformer transforms it all to
|
by: Nahappan SM |
last post by:
I have a struct :
#include <string>
struct __declspec (dllexport) FILEPROPERTIES
{
std::wstring FileName;
std::wstring Type;
};
|
by: Jack Addington |
last post by:
I have created an event and delegate combination for use in a user control
when I place it on a form. However because I'm not actually doing anything
in the event in the user object I didn't...
|
by: Steve Franks |
last post by:
Every time I rebuild my ASP.NET site (2005 beta 2) I get the following
warning, and I cannot figure out where it is coming from and how to resolve
it:
Warning 1 The type 'myquicktest' in...
|
by: Rob R. Ainscough |
last post by:
When I run my Test application I get the following error:
Warning: The dependency 'MyCompany.Utilities, Version=1.0.1852.27525,
Culture=neutral' in project 'MyCompany.Remote' cannot be copied to...
|
by: Edge1960 |
last post by:
I am using Visual Web Developer along with SQLExpress on a WinXP Pro
2002 SP2 machine with a 3.79 GHz processor with 2GB of RAM to create
a
web application for entering data to a database. I am...
|
by: chennaibala |
last post by:
can any one send me mutiple image upload program and save the file name with extension in mysql table.we must cheak uploaded file type like bmp or any image file while uploading.
i develop...
|
by: thatcollegeguy |
last post by:
http://smarterfootball.com/exits/theHTML.html
I am not sure what is wrong w/ this code. The main issue is that the table that is in the initial html will empty its td but the table that I load...
|
by: ROXIT |
last post by:
Hello Everyone please help me to sort out this warning..
The below code is successfully running and all the data get successfully save into the database along with the photo which user uploads...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |