473,466 Members | 1,460 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how to declare the uploaded picture on submition page

4 New Member
album.php-part of code without connection function
Expand|Select|Wrap|Line Numbers
  1. <form action="submit.php" method="post" enctype="multipart/form-data" name="form1" id="form1" onSubmit="return requiredCheck(this);">
  2. <table><td>
  3.   <tr><input name="file" type="file" id="file" 
  4.       class="txt_blacknormal" size="40" /></tr>
  5. </td>
  6. <td><tr> <input name="Submit" type="submit" value="Submit" /></tr></td></table>
  7. <form>
  8.  
submit.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. include "session.php";
  3. include "function.php";
  4. $adminalbum = new Adminalbum;
  5.  
  6. if (@$_POST['Submit'] == "Submit")
  7. {    
  8.     $cname =$_POST['cname'];
  9.     $cdesc=$_POST['cdesc'];
  10.     $file1=$_POST['file'];
  11.  
  12.     $info =$cname;
  13.      $id2 = session_id();
  14.     $ip_address =  "$_SERVER[REMOTE_ADDR]"; 
  15.     session_register("info");
  16.     if (!$admincate->checkCate($cname))
  17.         {
  18.             header("Location: albumnew.php?m=ext");                        
  19.         }
  20.         else{
  21.  
  22.             $cid = $admincate->getNewID('c','cid','category');
  23.             if ($admincate->addCate($cid,$cname,$cdesc,$file,$file_name))
  24.             {
  25.                 session_unregister("info");
  26.  
  27.                 header("Location: albumreview.php?cid=$cid");    
  28.  
  29.             }
  30.             else
  31.             {
  32.                 echo "<SCRIPT>alert(\"Database Error! Unable to add data into database!\");history.go(-1)</SCRIPT>";
  33.             }
  34.         }
  35.  
  36. }
  37. ?>
  38.  
function.php
Expand|Select|Wrap|Line Numbers
  1. <?
  2. include "admin_connectDB.php";
  3. class adminalbum{
  4. function addCate($cid,$cname,$cdesc,$file,$file_name)
  5.     {
  6.     if($file!='' && $file!='none')
  7.         {
  8.             $path = "../albumpic/$file_name"; 
  9.             $query = "SELECT cpic FROM category WHERE cpic = '$path'";
  10.             $result = mysql_query($query);
  11.             if(mysql_num_rows($result)!=0)
  12.             {
  13.                 $file_path = $this->generate_num('albumpic',$file_name,'cpic','category');
  14.                 $path = "../albumpic/$file_path";
  15.             }
  16.             copy($file, $path);
  17.  
  18.         }
  19.         else
  20.         {
  21.             $path = "";
  22.         }            
  23.         $query1 = "INSERT INTO category  VALUES('','$cid','$cname','$cdesc','$path','','','')";
  24.         $result1 = mysql_query($query1);
  25.         if ($result1)
  26.         return true;
  27.         else
  28.         return false;
  29.     }
  30. }
  31. ?>
  32.  
Apr 4 '11 #1
1 1571
chin Tang
4 New Member
All of the datas can insert into database but just the uploaded picture data was failure to insert.
Apr 4 '11 #2

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

Similar topics

2
by: matt | last post by:
I have compiled some code, some written by me, some compiled from various sources online, and basically i've got a very simple flat file photo gallery. An upload form, to upload the photos and give...
7
by: Michael Jaeger | last post by:
Dear ciwah, I'm in the process of designing a German school web site, and I need the help of you experts. I wrote the navigation (CSS based, no javascript), which looks OK in IE, Firefox and...
3
by: Ig | last post by:
Hi, I have an embedded picture with caption on tab page and want to make it appear and disappear when certain conditions happen. To make it disappear I just code it like : Me!MyTab.Picture = ""....
7
by: Max | last post by:
How do I declare in the parent page's code behind a user control? I want to call a sub that is located in the user control. Want to do something like this: Call MyUserControl.MySub()
5
by: Brian Lowe | last post by:
My web site accepts uploaded photos and stores them in a SQL table as BLObs so they never touch the filesystem. I have a way to create a thumbnail version of the uploaded image and store that in...
8
by: -Karl | last post by:
Apparently, asp.net has a posting issue with refreshing. There seems to be several solutions to the issue but I was wondering if there is a final workaround for the issue? If so, can you please...
18
by: J-T | last post by:
Hi All, There is a picture on the following URL which I want to have it in one of my asp.net pages .I mean I want to embed the content of this page in my own page and get its image.Is there a...
1
by: jhcorey | last post by:
This is an ASP.NET 2.0 question. In 1.0, common techniques for communicating between a page and the controls on it depended on being able to declare variables of the page and control types....
8
by: Rasmus Teglgaard | last post by:
Hi I'm trying to get a picture uploaded to the picture attribute in Active Directory. I've got most of it working, the only thing I need now, is to convert this picture to a byte array, so that I...
3
oranoos3000
by: oranoos3000 | last post by:
hi i'm a beginer javascript would you please help me i d like to findout this page has next page or previous page in history object i use this line of code if(window.history.length>0) and with...
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...
1
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...
0
tracyyun
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...
0
agi2029
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,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.