Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving path and file name in MYSQL

Status
Not open for further replies.

kjspear

Programmer
Feb 13, 2002
173
US
I would like to use two fields, one fr a path and one for a filename. Or can I simply have one field which contains the PATH field and add or concat the file name that the user selects from his/her hard drive? I know that the syntax below is not correct, but just to give you an idea;

$uploaddir = 'c:/mysql/data/mylogin/upimages/'+FILENAME;

This way the enite path can be stored in the database such as;

c:/mysql/data/mylogin/upimages/FILENAME.PHP;

I would then have mysql retrive this record and send it the an HTML or PHP file for output. This would use the SRC command to display the image.

Any assistance would be helpful.

Thanks

KJ

 
Not sure if the file is an image or a php or html file but You can store the path and the filname in one field.
In that case u can simply fetch one column in DB and use it in ur html/php file.


--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
O.K., so basically how would I include the field name with the path name. Such as;

$uploaddir = 'c:/mysql/data/mylogin/upimages/'+FILENAME;

Where FILENAME is what the file the user selected from his/her directory to upload. I know the '+' sign will not do this. When I did this, it gave me a result of 0. What is the proper syntax to join the two together, so that when it's fetched it will read the enitre path and filename?

Thank you.
KJ
 
To simplify the things, u can make one variable and insert that into ur table.If ur storing image, u need to put it in SRC attribute of IMG tag.
eg
Code:
$pathoffile = "[URL unfurl="true"]http://www.ursite.com/images/"[/URL] ;
$image = pathoffile.$file_name ;// $file_name contains the name of the file user has uploaded."." concats  strings in PHP
then insert $image into ur table
while displaying the image
Code:
// get the image from the database
echo &quot;<img src=\&quot;$image\&quot;...>&quot; ;// $iamge contains the full path of the image ie [URL unfurl="true"]http://www.ursite.com/images/image1.gif[/URL]




--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top