Hi
I am having trouble writing the file path of a image to the
database,also for some reason it is not uploading the images, anyone
have any ideas?
the code is below:
if($_POST[Submit] == 'Submit')
{
$target_path = "../reviewImages/";
$target_path = $target_path . basename(
$_FILES['uploadFile']['name']);
if(move_uploaded_file($_FILES['uploadFile']['tmp_name'],
$target_path)) {
echo "The file ". basename( $_FILES['uploadFile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try
again!";
}
echo $target_path;
$text = $_POST[text];
$press = $_POST[press];
$logo = "reviewImages/".basename( $_FILES['uploadFile']['name']);
echo $logo;
$title = $_POST[title];
$author = $_POST[author];
$date = $_POST['date'];
$sql = "INSERT into reviews (press, title, author, date, text,
imagePath) VALUES ('$press', '$title', '$author', '$date', '$text',
'$logo')";
mysql_query($sql) or die(mysql_error());
echo "Information added to the reviews table";
}
cheers
Glenn 1 2352
Check if you're using enctype="multipart/form-data" on the form. More
info here: http://us3.php.net/features.file-upload
Example:
<form enctype="multipart/form-data" action="post.php" method="POST">
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>
Glenn Coyle wrote:
Hi
I am having trouble writing the file path of a image to the
database,also for some reason it is not uploading the images, anyone
have any ideas?
the code is below:
if($_POST[Submit] == 'Submit')
{
$target_path = "../reviewImages/";
$target_path = $target_path . basename(
$_FILES['uploadFile']['name']);
if(move_uploaded_file($_FILES['uploadFile']['tmp_name'],
$target_path)) {
echo "The file ". basename( $_FILES['uploadFile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try
again!";
}
echo $target_path;
$text = $_POST[text];
$press = $_POST[press];
$logo = "reviewImages/".basename( $_FILES['uploadFile']['name']);
echo $logo;
$title = $_POST[title];
$author = $_POST[author];
$date = $_POST['date'];
$sql = "INSERT into reviews (press, title, author, date, text,
imagePath) VALUES ('$press', '$title', '$author', '$date', '$text',
'$logo')";
mysql_query($sql) or die(mysql_error());
echo "Information added to the reviews table";
}
cheers
Glenn
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: A |
last post by:
Hi everyone
I was working on a php script to display images and I am running into
problems. My problems are when I execute the query to thumb path it won't
display the image/s.
Anyhelp is...
|
by: DaRemedy |
last post by:
Hiya,
Can anyone kindly help me to get started in creating a PHP/MySQL image
gallery, it doesn't have to be anything fancy, just something that
automatically reads the images in the folder and...
|
by: dave |
last post by:
Hello there,
I am at my wit's end ! I have used the following script succesfully to
upload an image to my web space. But what I really want to be able to do is
to update an existing record in a...
|
by: david |
last post by:
Hi,
I have asp pages running from a MySQL database.
I have placed a path in the required field (although not quite sure on
the correct format).
My asp page is just displaying the text path...
|
by: Nikki |
last post by:
I have a database, front and data backend, I have written in Access 97
and it has been chugging along for the last 6 years all with constant
updates except for the last year with almost no...
|
by: jackpod |
last post by:
Hi,
I have been trying to write an image to a database table BLOB field in
MySQL but when I try to retrieve the image to display it, it shows as
being empty. Are there any special considerations I...
|
by: gsoguerrilla |
last post by:
Hi,
I have limited knowledge in php and I am having trouble with uploading
an image to a remote directory and resizing it if it's larger and
renaming it to a unique id, while at the same time I...
|
by: swetha123 |
last post by:
hello,
Can any one please tell me
I am Using php,Mysql,CSS to build my site
In my database i have small images and large images
i am show the small images to the right of the main container...
|
by: swetha123 |
last post by:
hello,
Can any one please tell me
I am Using php,Mysql,CSS to build my site
In my database i have small images and large images
i am show the small images to the right of the main container...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |