Phpmyadmin And Dreamweaver8 Uploading Picture Issues

Welcome. Please Login, Register, Or Activate! 
type your username and password to login
Date: November 23, 2009, 06:14 AM
431070 members and 298133 Topics
Latest Member: wilfrotech
Nairaland [Nigerian Forum] Home Help Search Who is currently online? Login Register
Nairaland Forum  |  Technology  |  Webmasters (Moderators: OmniPotens, yawa-ti-de)  |  Phpmyadmin And Dreamweaver8 Uploading Picture Issues
Pages: (1) Go Down Send this topic Notify of replies
Author Topic: Phpmyadmin And Dreamweaver8 Uploading Picture Issues  (Read 1191 views)
pholusho (m)
Phpmyadmin And Dreamweaver8 Uploading Picture Issues
« on: December 03, 2008, 10:54 AM »

hello yah all, am having this little problem, i created this page which as a file field component i intend to use it for uploading pictures to my database, but when i tried it i did not submit to the database at all but i have been able to submit text to the database.please bear in mind that i make use of php my admin and macromedia dreamweaver(dont know php codes that much, but can use echo lol Grin ). Please kindly help me out thank you.
smartsoft (m)
Re: Phpmyadmin And Dreamweaver8 Uploading Picture Issues
« #1 on: December 03, 2008, 11:52 AM »

there is a whole lot, when talking about dumping images to your database,  you must create a temp file on your server and emmmmmmmmmmmmmmm hang brb,
pholusho (m)
Re: Phpmyadmin And Dreamweaver8 Uploading Picture Issues
« #2 on: December 06, 2008, 07:52 PM »

still no solutions yet,
pholusho (m)
Re: Phpmyadmin And Dreamweaver8 Uploading Picture Issues
« #3 on: December 06, 2008, 09:28 PM »

please dont tell me nobody as a clue about this
yawa-ti-de (f)
Re: Phpmyadmin And Dreamweaver8 Uploading Picture Issues
« #4 on: December 07, 2008, 12:23 AM »

I would have a clue if you didn't use a DW component so sorry, but I can't help you on this.

Possible issue: The type of data type specified for the image column (I blv it shd be BLOB)
pholusho (m)
Re: Phpmyadmin And Dreamweaver8 Uploading Picture Issues
« #5 on: December 07, 2008, 08:17 AM »

Thanks yawatide, you mean i should specify my data type on to be blob, believe me i have done that but dreamweaver would not just submit it to the database, what do i do now,
yawa-ti-de (f)
Re: Phpmyadmin And Dreamweaver8 Uploading Picture Issues
« #6 on: December 07, 2008, 01:41 PM »

I am sorry but like I said, I don't use DW.  As a matter of fact, I loathe it with a passion.  Hopefully some DW users in here will help you out.
uspry1 (f)
Re: Phpmyadmin And Dreamweaver8 Uploading Picture Issues
« #7 on: December 07, 2008, 02:19 PM »

I hope you do know how to set up MySQL connection using Dreamweaver 8 like this link tutorial below:

http://www.nebulex.com/index.php?option=com_content&view=article&id=6&Itemid=62

Then you create your own dynamic form using Dreamweaver recordset to upload pictures into MySQL database for STORING or RETRIEVING purpose. You will need Dreamweaver extension (component) called PHP Upload from Adobe.com or below link from DMXzone.com:

http://www.dmxzone.com/showDetail.asp?TypeId=25&NewsId=6346

Basically you should know how to use PHP, MySQL and Dreamweaver recordset to make Picture upload work. There are few Dreamweaver database with upload picture tutorials found on books as well as Adobe.com.

Good luck!
kehers (m)
Re: Phpmyadmin And Dreamweaver8 Uploading Picture Issues
« #8 on: December 07, 2008, 02:35 PM »

To start wit, it is not advisable to store up images in your db fields. Store it in a folder snd store the imae path in the db instead.
Attached is a snippet for that
Quote
<?php
if(move_uploaded_file($_FILES['source']['tmp_name'], "foldername/".$_FILES['source']['name'])){
   //query
   $r = mysql_query("insert into tableName (src, size) values ('".$_FILES['source']['name']."', '".round($_FILES['source']['size']/1024."')");
   if($r){
      //upload success
   }
   else{
      //sql query error
      //echo mysql_error();
   }
}
else{
   //Upload error
}
?>
And if you must store it in a db, simply make the data type f the field blob (binary large object - if Im correct) as Yawa said and once u upload, use any of the php file functions to read the content (binary) and it is that u insert into the db. Here is a simpel analogy:
Quote
<?php
$filecontent = file_get_contents('path/to/uploaded/file.ext');
$sql = "insert into tbl (px) values ('$filecontent')";
//, the query and otherthings follows
?>
pholusho (m)
Re: Phpmyadmin And Dreamweaver8 Uploading Picture Issues
« #9 on: December 08, 2008, 08:42 AM »

uspry1 thanks for your advice, but you see i know how to connect to the database, insert records to my database, but i tried usin the file field but it is not just working i tried connecting it the same way you connect a text input field and also made sure i specified blob for data type when i tested it on my browser it did not submit an error message comes up like field cannot be null. i will also check on the links you dropped and i'll come and give you a feed back chao. @all thanks for your opinions too.
pholusho (m)
Re: Phpmyadmin And Dreamweaver8 Uploading Picture Issues
« #10 on: December 08, 2008, 09:00 AM »

yeah i tried the same process again now its submitting to the database showing [blob-null] but i cant see the pix it self so i tried creating a new page with a dynamic table which display the recordset from my database field picture but when i tried running it the picture didnt show. please what should i do.
kehers (m)
Re: Phpmyadmin And Dreamweaver8 Uploading Picture Issues
« #11 on: December 08, 2008, 03:39 PM »

The null means no data is inserted in the field. Are u sure the image is uploaded in the first place?
Quote
   <form action="" enctype="multipart/form-data" method="post">
   <input type="hidden" name="MAX_FILE_SIZE" value="524280">
   Picture source: <input type="file" name="source"  />
  <input type="submit" value="Upload" />
    </form>
The MAX_FILE_SIZE parameter is important and should come before your input file. its value is the maximum bytes allowed (here it is set to around 5MB). Take note of the form enctype as well. For uploads, it should be set to multipart/form-data
kehers (m)
Re: Phpmyadmin And Dreamweaver8 Uploading Picture Issues
« #12 on: December 08, 2008, 04:00 PM »

LAst post's edit. The MAX size specified there is 500KB and not MB.
That said, the next thing is handling the uploaded image. First, create a folder called tmp and then handle the submission this way
Quote
   $err = array(
      0=>"There is no error, the file uploaded with success",
      1=>"The uploaded file exceeds the maximum upload filesize",
      2=>"The uploaded file exceeds the maximum upload filesize",
      3=>"The uploaded file was only partially uploaded",
      4=>"No file was uploaded",
      6=>"Missing a temporary folder"
   );
         if(move_uploaded_file($_FILES['source']['tmp_name'], "tmp/".$_FILES['source']['name'])){
            $filecontent = file_get_contents("tmp/".$_FILES['source']['name']);
            //query
            $r = mysql_query("insert into tbl (src) values ('".mysql_escape_string($filecontent)."')");
            echo mysql_error();
         }
         else{
            echo 'Upload Error: '.$err[$_FILES['source']['error']];
         }
kehers (m)
Re: Phpmyadmin And Dreamweaver8 Uploading Picture Issues
« #13 on: December 08, 2008, 04:13 PM »

Im hoping you have average skills in PHP and Mysql so Ive purposely left out some more detailed parts. And by the way, the create sql for the tbl table Im using here goes like this
Quote
CREATE TABLE `tbl` (
  `id` int(11) NOT NULL auto_increment,
  `src` blob NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM

So lets continue. With the form and upload probably taken care of. The last worry is displaying the image. You actually need a script that will take of the image display. Lets call it image.php. Here is what it will contain:
Quote
<?php
mysql_connect("localhost", "db_usrname", "db_password");
mysql_select_db("ur_dbname");
//
$id = $_GET['id'];
$r = mysql_query("select src from tbl where id='$id'");
list($src) = mysql_fetch_array($r);
echo $src;
?>

So that from anywhere, u can simply call up any image stored in the tbl this way:

Quote
<img src="image.php?id=1" alt="Hmmm, " />

And thats all. The id of the needed image is simply passed to image.php where it is retrieved and the value of the blob field is outputted.
By the way, there may be better ways to achieve storing images in a database but this is the idea I have. Anyone with other ideas should please share.
Let me know if it works.
pholusho (m)
Re: Phpmyadmin And Dreamweaver8 Uploading Picture Issues
« #14 on: December 09, 2008, 08:15 PM »

kehers you are really appreciated but you see i dont know codes that much so most of those things looks like magic to me is there know way that i could do this with dreamweaver without using codes?
kehers (m)
Re: Phpmyadmin And Dreamweaver8 Uploading Picture Issues
« #15 on: December 09, 2008, 09:50 PM »

Sorry to burst your bubbles but i dont do DW as well. We can only hope another developer in d house will help out on d DW part.
pholusho (m)
Re: Phpmyadmin And Dreamweaver8 Uploading Picture Issues
« #16 on: December 09, 2008, 09:56 PM »

@kehers what software do you use?
kehers (m)
Re: Phpmyadmin And Dreamweaver8 Uploading Picture Issues
« #17 on: December 09, 2008, 10:17 PM »

I code directly in Editplus (an editor like d notepad, notepad++, and co)
pholusho (m)
Re: Phpmyadmin And Dreamweaver8 Uploading Picture Issues
« #18 on: December 12, 2008, 03:36 PM »

i have gotten my hands on a book on php and mysql i hope it helps, thank yall for you advice and support
uspry1 (f)
Re: Phpmyadmin And Dreamweaver8 Uploading Picture Issues
« #19 on: December 13, 2008, 09:04 PM »

@pholusho

You are more than welcome and wish you the best luck to work on php and MySQL using Dreamweaver 8.
yankitwizy (m)
Re: Phpmyadmin And Dreamweaver8 Uploading Picture Issues
« #20 on: December 15, 2008, 10:30 AM »

I do use dreamweaver and phpmyadmin as well and it is true that with dreamweaver you could do a lot of PHP stuff without writing one single code but the truth is to do this particular thing you want, you must write code. There are no two ways about it. If you don't write then you can't get this done.
pholusho (m)
Re: Phpmyadmin And Dreamweaver8 Uploading Picture Issues
« #21 on: December 16, 2008, 02:29 PM »

thanks at all. now am onto coding it my self but note pad is just messing up, meaning when i write my php codes with note pad the browser don't display the desired ouput,  but when i used the same codes in the code section of dreamweaver they work well what could be wrong?
yawa-ti-de (f)
Re: Phpmyadmin And Dreamweaver8 Uploading Picture Issues
« #22 on: December 16, 2008, 03:29 PM »

How are you saving your files?

In notepad, if you don't select "all files" from the "save" or "save as" dropdown, your file will be saved like so, "flename.php.txt" so it is important that you select "all files" under the "file type" menu to preserve the .php extension.  If you don't want to go that route, then enclose your file name in double quotes when you name  it.

Hopefully, this solves your problem using notepad.
webdezzi (m)
Re: Phpmyadmin And Dreamweaver8 Uploading Picture Issues
« #23 on: December 18, 2008, 07:18 PM »

Kehers and yankitwizy has answered it all

Dreamweaver will not help you, you have to code it urself
Talking about notepad, for a newbie like you, i will advise you still use the code view of dreamweaver, set the enctype of the form to multipart/form-data
use kehers codes and you should be fine

However, i dont like storing my image in databases for some special reasons, but if thats what you want you will have to set the database column type to BLOB and note that blob does not require a character length

Kehers has posted all these already, so he might be able to help  if you stil have problem
*dhtml
Re: Phpmyadmin And Dreamweaver8 Uploading Picture Issues
« #24 on: December 23, 2008, 10:16 PM »

The interesting thing i find here is that, i was not the only person that hate DW, i have written a number of scripts, classes in javascript, php, and i have a whole lot of very useful libraries, and i achieved this without DW, and NotePad++ is my favorite editor.
Now i am tryin to go all ajax like my new subsite http://www.ds.mwebng.net uses alot of ajax stuffs, but if u are a DW person, u cant benefit from alot of stuffs, u must wait for DW to get there.
It is not just me, many professionals find it tough to do sophisticated coding in DW, it is more difficult that to handcode directly using classes and all that.
So it is either u are fully into DW or NOT! and i prefer NOT!
There are lots of free php uploader scripts online, just type it into google, integratin it into DW especially for a beginner can be quite tough!!
I guess that is why most people kept quiet, even i cannot post any code here to help you, and yet had u asked for how to upload images without reloading the page, i will post back codes to u, but again, they will not work easily with DW!
webdezzi (m)
Re: Phpmyadmin And Dreamweaver8 Uploading Picture Issues
« #25 on: December 25, 2008, 08:58 PM »

me i love dreamweaver ooo
*dhtml
Re: Phpmyadmin And Dreamweaver8 Uploading Picture Issues
« #26 on: December 28, 2008, 09:24 PM »

And what is the hashbang #!/usr/bin/girl on your profile meant to do? open a door for girls or what?
Anyway, no problemo, carry go, i can use DW too but to a limited extent.
*dhtml
Re: Phpmyadmin And Dreamweaver8 Uploading Picture Issues
« #27 on: December 28, 2008, 09:31 PM »

And what is the hashbang #!/usr/bin/girl on your profile meant to do? open a door for girls or what? it is obviously not perl unless maybe the cgi-bin directory has been changed to bin-girl or something.
Anyway, no problemo, carry go, i can use DW too but to a limited extent. Anyway, my script library is quite large and i can code quite fast.
We could do a competition some day, DW vs NP++ [but i will have access to my personal script library sha] - and we will see who will win - 1st prize - ehm?  one enterprise project [i mean a big project for a client - of course from the looser]!!
webdezzi (m)
Re: Phpmyadmin And Dreamweaver8 Uploading Picture Issues
« #28 on: December 29, 2008, 07:21 PM »

thats a perl path for use girls and dump them (Please don't ask me if i do it)

About DW, I see loads of advantages it has over many web authoring softwares out there

1. Has code coloring like others
2. with the assets panel, i can preview my images without having to drag them in to see which image is which, a time saver
3. Snippets panel allows me to save frequently used codes, so i just double click to have it in my script
3. I find the inbuilt FTP very useful in special situations, though i rely mostly on CuteFTP
4. Using DW's tools for generating code help build SECURE websites, This is best for beginners as they transition into being a pro, They have nothing to fear
5. the dreamweaver exchange allows you to install some ajax  extensions so you can build ajax sites right from dreamweaver
6. The design view allow preview, so you don't have to switch to the web browser at an initial stage of development
7. The code view gives you the flexibility of remaining a hardcore programmer that you want to be

So why shouldn't i love this baby
*dhtml
Re: Phpmyadmin And Dreamweaver8 Uploading Picture Issues
« #29 on: December 31, 2008, 11:10 PM »

You are very correct about all that - DW is excellent - though some of us that all we do is coding and loads of it - though some times i do have to rely on it.
I still even use FRONTPAGE atimes to do image mapping - but now, i prefer to my mapping direct from macromedia fireworks - anyways i will like you guys to contribute to the thread i just started - it is on http://nl.mwebng.net/ - that is a redirection path to the thread here on nairaland - talking about dynamic website design featuring javascript, dom, ajax, css,
 Breaking News: Vtn Mobile Payment Pilot Rollout In Nigeria  Nipost Website - Read This!  Guess What? Show Off Time  Page 2
Pages: (1) Go Up Send Topic to Friend by E-mail Reply 


Sections: Autos/Cars (2) Jobs/Vacancies (2) (3) Career Talk Education General(2) Politics Romance Computers Phones Travel
Sports Fashion Health Religion Celebrities TV/Movies (2) Music/Radio (2) Books Webmasters Programming

Links: Page1 Page2 Page3 Page4 Page5 Page6 Page7 Page8 Page9 Page10

Nairaland is owned by Oluwaseun Osewa. See also: Nairalist Classified Ads
Nairaland Forum | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.