GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 08-Dec-2006, 19:38
Richardknox Richardknox is offline
Junior Member
 
Join Date: Nov 2006
Location: Michigan
Posts: 83
Richardknox is on a distinguished road

Transfer longblob from one table to another table


Greetings,

I am using one table as an upload area for pictures, to be reviewed later prior to them being placed online for public viewing.

I am keeping the upload table seperate from the main table.

I am able to transfer everything over, but the longblob. Is there anything special that needs to be done, to transfer images fromone table to another table??

Thanks,
Richard
  #2  
Old 09-Dec-2006, 21:27
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough

Re: Transfer longblob from one table to another table


I have never stored images in the database, so I can't think of anything that might prevent one from 'moving' such data around.

I usually store the images in the filesystem, but I keep record of the filename in the database. So if I want to show image ID No.23, I just fetch the row, get the filename and read the file to do what I want with it.

Maybe the fault is in your 'transfer image' script? In other words, show us what you used (script) to transfer the image.
  #3  
Old 10-Dec-2006, 00:26
TurboPT's Avatar
TurboPT TurboPT is offline
Senior Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 1,140
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: Transfer longblob from one table to another table


Same here, Richard. We also store only the filename in our DB(s), and all the files are in a specific directory. (The path is set in a define statement for use within the program)
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
  #4  
Old 10-Dec-2006, 08:17
Richardknox Richardknox is offline
Junior Member
 
Join Date: Nov 2006
Location: Michigan
Posts: 83
Richardknox is on a distinguished road

Re: Transfer longblob from one table to another table


The only reason I went with placing the image into the database, was some information that I had recieved on the internet. Now, if what I am doing is not the smart thing, then I can easily go the other direction and place the images into a seperate directory.


Richard
  #5  
Old 10-Dec-2006, 09:13
Richardknox Richardknox is offline
Junior Member
 
Join Date: Nov 2006
Location: Michigan
Posts: 83
Richardknox is on a distinguished road

Re: Transfer longblob from one table to another table


I currently have a submital page for a visitor to my site to input all the information, and then include an image to upload to the site. That inputed image was placed into the database, in the same row as the rest of the information, related to the image. I use a form for the input of the information.


PHP Code:

<?php

include "db_connection.php";   //Includes mysql connection information

// database connection
$dblink = mysql_connect($dbhostname,$dbusername, $dbpassword) OR DIE ("Unable to connect to database! Please try again later.");
@mysql_select_db($dbname, $dblink);


// Do this process if user has browse the file and click the submit button
if ($_FILES) {
  $image_types = Array ("image/bmp",
                        "image/jpeg",
                        "image/pjpeg",
                        "image/gif",
                        "image/x-png");

  @$userfile  = addslashes (fread (fopen ($_FILES["userfile"]["tmp_name"], "r"), filesize ($_FILES["userfile"]["tmp_name"])));
  $file_name = $_FILES["userfile"]["name"];
  $file_size = $_FILES["userfile"]["size"];
  $file_type = $_FILES["userfile"]["type"];

  if (in_array (strtolower ($file_type), $image_types)) {
    $sql = "INSERT INTO wcsubmittal (camname, country, state, city, sdesc, url, link, gmt, weather, catagory, added, email, addeddate, imagedate, imagetype, imagesize, image_name, image) VALUES ('$camname', '$country', '$state', '$city', '$sdesc', '$url', '$imageurl', '$timezone', '$metar', '$catagory', '$fullname', '$email', NOW(), NOW(), '$file_type', '$file_size', '$file_name', '$userfile')"; 
    @mysql_query ($sql, $dblink);

exit();
  }
}

// Do this process if user has browse the 
// file and click the submit button

?>



1.) How can I change this to allow for saving the file into a directory on the site.

2.) Another reason I had placed the file in the database, is that sometimes the images have the same name. (webcam, default, pic, etc...), thus I don't have to worry about the name conflicting in the database.

I'll take any suggestions, or help.

Thanks,
Richard
  #6  
Old 10-Dec-2006, 19:31
Richardknox Richardknox is offline
Junior Member
 
Join Date: Nov 2006
Location: Michigan
Posts: 83
Richardknox is on a distinguished road

Re: Transfer longblob from one table to another table


I decided from reading the previous two replies, and decided to adjust my script to allow for the filename to be saved in a seperate directory on the website. The only thing I need know,, is how to create randomized names, thus preventing accidental same name collisions.
  #7  
Old 13-Dec-2006, 05:26
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough

Re: Transfer longblob from one table to another table


The point is that you want to avoid overwriting image files. How you do this is entirely up to you.

The obvious thing to do is to:
  1. see if the filename exists in the directory with PHP's file_exists() function
  2. rename the file if a file with the same name exists

You can login to GIDNetwork and there is an option for you to upload images. Try uploading a couple and try to use the same name for each. Maybe I didn't check for duplicate names (now that you mentioned it) . Let me know if the script crashes...
 
 

Recent GIDBlogProblems with the Navy (Chiefs) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need-Space.co.uk | Reseller and Shared Hosting Plans! nsuk Web Hosting Advertisements & Offers 0 28-Jul-2006 08:01
Need-Space.co.uk | Reseller and Shared Hosting Plans! nsuk Web Hosting Advertisements & Offers 0 19-Jul-2006 09:31
Need-Space | Reseller and Shared Hosting Plans! nsuk Web Hosting Advertisements & Offers 0 23-Jun-2006 11:07
Need-Space | Reseller and Shared Hosting Plans! nsuk Web Hosting Advertisements & Offers 0 06-Jun-2006 14:43
Cannot create a table in DB WaltP MySQL / PHP Forum 3 26-Apr-2006 17:09

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 09:10.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.