473,396 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

retrieveing browsed file and save it into mysql database

Hi !
I'm a php developer.
I'm developing a site into which I have to upload a text file and a image file
from users through a browse box and then I have to retrieve that file and save it
into mysql database .Should I use POST method to retrieve the browse box
value that have been uploaded with a text file or image file.For example :-

<html>
<body>
<form method="post" action="test.php">
<input type="file" name="file_read" id="file_read">
<?php
$temp_var=$_POST["file_read"];
?>
</form>
</body>
</html>
May 1 '07 #1
1 2209
Hi !
I'm a php developer.
I'm developing a site into which I have to upload a text file and a image file
from users through a browse box and then I have to retrieve that file and save it
into mysql database .Should I use POST method to retrieve the browse box
value that have been uploaded with a text file or image file.For example :-

<html>
<body>
<form method="post" action="test.php">
<input type="file" name="file_read" id="file_read">
<?php
$temp_var=$_POST["file_read"];
?>
</form>
</body>
</html>
Hi!
I dont understand why you would wanna browse later andd do such gimmicks. Further, once the user on your site uploaded and image and when the image is in your server directory, how would you know that this is the image that belongs to him and this would post serious problems when you were to have several users. If however you have to do it this way, then I suggest that when you get the image filename while it is uploaded, concatenate the filename with the user name. But this is such an inconvinient tech.

A simplsitic approach would be to have a field named image (say) in your database. Now when the user uploads a file, get the filename using php fuctions. and then perform a simple query.
could be like

INSERT INTO db.table_name(name,image) VALUES ('name','file_name' )
So then this is an easier way.

In this way, you have the user's name and the name of the file the user has uploaded. Thereby whenever you wanna open/use this file, you can use the name of the file stored in the image field of your database. This file name / image name now points to that file located on your server directory. thereby when you say something like <img src="<?php echo $image_name?>">, this would actually query the database fetch that image name which actually points to the file / image in your server directory.

Now lets assume the user registers first wand wants to upload an image later,
the the query would be: (Assuming there is an option to upload later)

UPDATE db.table_name SET image='file_name' WHERE name = 'person_already_registered_but_uploading_now';

Hope I am op help to you.

CyberKing
http://www.bytesandbytes.com
May 1 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Johnny | last post by:
I was looking for information on how to import an excel file or other text file into a MySql database. I have done this with both access and SQL Server and am looking for a way to do this in...
8
by: Johnny | last post by:
I was looking for information on how to import an excel file or other text file into a MySql database. I have done this with both access and SQL Server and am looking for a way to do this in...
2
by: Waqas.L.Khan | last post by:
Hi Guys, I'm doing some work with richtextboxes and want to be able to save and load the content from them to a mysql database (including all formatting). I figured the best way to do this would...
2
by: Ravigandha | last post by:
Hello everybody, My question is how to insert special characters and symbols in Mysql5 database and how to retrieve them from database in php. Here i am inserting some data from a form,by post...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.