can any one send me mutiple image upload program and save the file name with extension in mysql table.we must cheak uploaded file type like bmp or any image file while uploading.
i develop program,which can upload many file in folder.problem is,am unable to save my file name in to database.becaus e i used same name for all input file type as file[]. i dont know get name of file.below i presented my coding for ur view.fed up with my coding..pls guide with new coding r suggest in my coding - <?php
-
-
// make a note of the current working directory relative to root.
-
$directory_self = str_replace(basename($_SERVER['PHP_SELF']), '', $_SERVER['PHP_SELF']);
-
-
// make a note of the location of the upload handler
-
$uploadHandler = 'http://' . $_SERVER['HTTP_HOST'] . $directory_self . 'multiple.upload.php';
-
-
// set a max file size for the html upload form
-
$max_file_size = 30000000000; // size in bytes
-
-
// now echo the html page
-
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
-
"http://www.w3.org/TR/html4/strict.dtd">
-
-
<html lang="en">
-
<head>
-
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
-
-
<link rel="stylesheet" type="text/css" href="stylesheet.css">
-
-
<title>Upload form</title>
-
-
</head>
-
-
<body>
-
-
<form id="Upload" action="<?php echo $uploadHandler ?>" enctype="multipart/form-data" method="post">
-
-
<h1>
-
Upload form
-
</h1>
-
-
<p>
-
<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size ?>">
-
</p>
-
-
<p>
-
<label for="file1">File to upload:</label>
-
<input id="file1" type="file" name="file[]">
-
</p>
-
-
<p>
-
<label for="file2">File to upload:</label>
-
<input id="file2" type="file" name="file[]">
-
</p>
-
-
<p>
-
<label for="file3">File to upload:</label>
-
<input id="file3" type="file" name="file[]">
-
</p>
-
-
<p>
-
<label for="submit">Press to...</label>
-
<input id="submit" type="submit" name="submit" value="Upload us!">
-
</p>
-
-
</form>
-
-
-
</body>
-
-
</html>
-
-
<?php
-
-
// make a note of the current working directory, relative to root.
-
$directory_self = str_replace(basename($_SERVER['PHP_SELF']), '', $_SERVER['PHP_SELF']);
-
-
// make a note of the directory that will recieve the uploaded files
-
$uploadsDirectory = $_SERVER['DOCUMENT_ROOT'] . $directory_self . 'uploaded_files/';
-
-
// make a note of the location of the upload form in case we need it
-
$uploadForm = 'http://' . $_SERVER['HTTP_HOST'] . $directory_self . 'multiple.upload.php';
-
-
// make a note of the location of the success page
-
$uploadSuccess = 'http://' . $_SERVER['HTTP_HOST'] . $directory_self . 'upload.success.php';
-
-
// name of the fieldname used for the file in the HTML form
-
$fieldname = 'file';
-
-
//echo'<pre>';print_r($_FILES);exit;
-
-
-
-
// Now let's deal with the uploaded files
-
-
// possible PHP upload errors
-
$errors = array(1 => 'php.ini max file size exceeded',
-
2 => 'html form max file size exceeded',
-
3 => 'file upload was only partial',
-
4 => 'no file was attached');
-
-
// check the upload form was actually submitted else print form
-
if(isset($_POST['submit']))
-
{
-
// or error('the upload form is neaded', $uploadForm);
-
-
// check if any files were uploaded and if
-
// so store the active $_FILES array keys
-
$active_keys = array();
-
foreach($_FILES[$fieldname]['name'] as $key => $filename)
-
{
-
if(!empty($filename))
-
{
-
$active_keys[] = $key;
-
}
-
}
-
-
// check at least one file was uploaded
-
count($active_keys)
-
or error('No files were uploaded', $uploadForm);
-
-
// check for standard uploading errors
-
foreach($active_keys as $key)
-
{
-
($_FILES[$fieldname]['error'][$key] == 0)
-
or error($_FILES[$fieldname]['tmp_name'][$key].': '.$errors[$_FILES[$fieldname]['error'][$key]], $uploadForm);
-
}
-
-
// check that the file we are working on really was an HTTP upload
-
foreach($active_keys as $key)
-
{
-
@is_uploaded_file($_FILES[$fieldname]['tmp_name'][$key])
-
or error($_FILES[$fieldname]['tmp_name'][$key].' not an HTTP upload', $uploadForm);
-
}
-
-
// validation... since this is an image upload script we
-
// should run a check to make sure the upload is an image
-
foreach($active_keys as $key)
-
{
-
@getimagesize($_FILES[$fieldname]['tmp_name'][$key])
-
or error($_FILES[$fieldname]['tmp_name'][$key].' not an image', $uploadForm);
-
}
-
-
// make a unique filename for the uploaded file and check it is
-
// not taken... if it is keep trying until we find a vacant one
-
foreach($active_keys as $key)
-
{
-
$now = time();
-
while(file_exists($uploadFilename[$key] = $uploadsDirectory.$now.'-'.$_FILES[$fieldname]['name'][$key]))
-
{
-
$now++;
-
}
-
}
-
-
// now let's move the file to its final and allocate it with the new filename
-
foreach($active_keys as $key)
-
{
-
@move_uploaded_file($_FILES[$fieldname]['tmp_name'][$key], $uploadFilename[$key])
-
or error('receiving directory insuffiecient permission', $uploadForm);
-
}
-
-
// If you got this far, everything has worked and the file has been successfully saved.
-
// We are now going to redirect the client to the success page.
-
header('Location: ' . $uploadSuccess);
-
-
// make an error handler which will be used if the upload fails
-
function error($error, $location, $seconds = 5)
-
{
-
header("Refresh: $seconds; URL=\"$location\"");
-
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"'."\n".
-
'"http://www.w3.org/TR/html4/strict.dtd">'."\n\n".
-
'<html lang="en">'."\n".
-
' <head>'."\n".
-
' <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">'."\n\n".
-
' <link rel="stylesheet" type="text/css" href="stylesheet.css">'."\n\n".
-
' <title>Upload error</title>'."\n\n".
-
' </head>'."\n\n".
-
' <body>'."\n\n".
-
' <div id="Upload">'."\n\n".
-
' <h1>Upload failure</h1>'."\n\n".
-
' <p>An error has occured: '."\n\n".
-
' <span class="red">' . $error . '...</span>'."\n\n".
-
' The upload form is reloading</p>'."\n\n".
-
' </div>'."\n\n".
-
'</html>';
-
exit;
-
} // end error handler
-
}
1 4882 Markus 6,050
Recognized Expert Expert
chennaibala,
Please understand that Bytes.com is a website dedicated to helping people solve their tech/IT related issues. It is not a site where you can request code and have it sent to you - that is against our forum guidelines[1].
Furthermore, when you post code, please use [code] your code goes here... [/code]. Again, this is a forum guideline[1].
If you would like to refine your question to target specific problems, and also show us that you are willing to do the work yourself, then post the question again as a reply to this thread.
Thanks,
Mark.
[1] Forum Guidelines Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Beowulf |
last post by:
Hi Guru's,
I have a query regarding using PHP to maintain a user profiles list. I
want to be able to have a form where users can fill in their profile
info (Name, hobbies etc) and attach an image, which will upload the
record to a mySql db so users can then either view all profiles or
query.. I.e. show all males in UK, all femails over 35 etc.
Now, I'm not asking for How to do this but more what would be the best
way? I've looked at...
|
by: Nomen Nescio |
last post by:
can anyone be so kind as to look at
http://www.mysolution.ws/HYPOCRITE.php
and let me know why it isn't passing the form data to
http://www.mysolution.ws/insertHYPOCRITES.php
for the most part, the scripts were created with
http://phpcodegenie.sourceforge.net/
|
by: dave |
last post by:
Hello there,
I am at my wit's end ! I have used the following script succesfully to
upload an image to my web space. But what I really want to be able to do is
to update an existing record in a table in MySQL with the path & filename to
the image.
I have successfully uploaded and performed an update query on the database,
but the problem I have is I cannot retain the primary key field in a
variable which is then used in a SQL update...
|
by: DH |
last post by:
I have a "file upload form" that works OK, but I have been unsuccessful
in my attempt to also resize the uploaded .JPG (if it is too wide),
over-writing the original .JPG, and then create and save a thumbnail.jpg
.... all at the same time. Links to a working example would be
appreciated. Thanks.
|
by: moondaddy |
last post by:
Using vb.net I need to download image files to the client browser where they
can save to disk. Below is some sample code I'm using. when I run this the
File Download window in the browser says:
File name: ViewAttachment
File type:
From localhost
1) "ViewAttachment" is the name of the aspx page and not the image file.
2) Its not picking up the file type of jpg. For ContentType I used
| |
by: Event Horizon |
last post by:
Hi,
I'm trying to add an simple upload applet to shopping cart script. My new
applet form sends all needed post fields ( quantity, product, etc... )
but the "file" post field is hardcoded in applet.
Shop script works with :
<input type="file" name="id"/>
but not with applet's:
<input type="file" name="SourceFile_1"/>
I just cannot figure out how to fix this :(
|
by: xx75vulcan |
last post by:
Hi,
I've got a PHP Upload Form that works great, unless that is, the image
your uploading has been modified through a photo editing software.
Example: if I upload the image straight from a camera or other, it
uploads fine. However, If I want to rotate the image, or resize it
with photoshop or simmilar, making sure to save it again as a jpg, the
PHP upload won't upload the image.
|
by: premprakashbhati |
last post by:
hi, good evening..
i am going to upload an image in a web form .....for that iam using HTML input(file) control and one web control button i.e., Upload_Button()
here is the code ...its work fine when iam using a normal web page... but can't in content page....
Code in Master Page
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="submaster.master.cs" Inherits="submaster" %>
<%@ Register Assembly="AjaxControlToolkit"...
|
by: neovantage |
last post by:
Hey all,
i have created image by mixing logo and the original image. It create image and show in the same window.
I have done 3 steps for this.
First i upload an image to my server by using move_upload_file, then i resize it using class "thumbnail.class.php"
My next step was to embed company logo in it(which i already done) and save new embedded logo image to the path where i first upload the original image i mean i want to overwrite...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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 we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |