Go Back   TechArena Community > Technology > Technology & Internet
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



How to upload images using PHP??

Technology & Internet


Reply
 
Thread Tools Search this Thread
  #1  
Old 25-11-2009
Member
 
Join Date: Nov 2009
Posts: 750
How to upload images using PHP??
  

I am developing a website in the language PHP. I cant understand how do I upload and display images using PHP. I am newly using this PHP to create a website, so I am not familiar how to do it. Whenever I click the SUBMIT button, it loads for a while and redirects me to a blank page. When I check the directory, I cannot find any images uploaded. Anyone who is familiar with this language, kindly suggest a solution.

Reply With Quote
  #2  
Old 25-11-2009
Member
 
Join Date: May 2008
Posts: 2,788
Re: How to upload images using PHP??

I know the code to create an upload button in a php form. Hope this works and you can use this button to browse images in php:
<?php
// filename: upload.form1.php
// first let's set some variables
// 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 script
$uploadHandler = 'http://' . $_SERVER['HTTP_HOST'] . $directory_self . 'upload.processor.php';
// set a max file size for the html upload form
$max_file_size = 30000; // 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="style.css">
<title>Form for upload button</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="maximum" value="<?php echo $max_file_size ?>">
</p>
<p>
<label for="file">File to upload:</label>
<input id="file" type="file" name="file1">
</p>
<p>
<label for="submit">Press to...</label>
<input id="submit" type="submit" name="submit1" value="Upload me!">
</p>
</form>
</body>
</html>

Last edited by Trio : 25-11-2009 at 11:53 PM.
Reply With Quote
  #3  
Old 26-11-2009
Member
 
Join Date: Apr 2008
Posts: 2,566
Re: How to upload images using PHP??

Try this stylesheet that I had used during making a website which had a feature to upload images using PHP:

#Upload
{
width: 20em;
margin: 1em auto;
padding:0 2em 2em 2em ;
border:1px solid #ccc;
color: #555;
background:#ddf;
font: 1em garamond, comic sans ms;
}

#Upload h1
{
font: 2em bold garamond, comic sans ms;
margin: 0;
padding:2em 0;
text-align:center;
}
#Upload label
{
float: left;
width: 9em;
}

#Upload p
{
clear: both;
}

.blue{
color:blue;
}
Reply With Quote
  #4  
Old 26-11-2009
Member
 
Join Date: May 2008
Posts: 2,134
Re: How to upload images using PHP??

You are not getting any error on the click of submit button. That means you are going right and there is no error. To upload images using PHP, you have to include a code that will redirect you to a particular page . Now you wont get a blank page.

<?php
// filename: successful.upload.php
?><!DOCTYPE HTML PUBLIC "-//W4C//DTD HTML 4.01//EN"
"http://www.w4.in/TR/html9/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 success</title>
</head>
<body>
<div id="Upload">
<h1>Upload file</h1>
<p>You have uploaded the file successfully</p>
</div>
</body>
</html>
Reply With Quote
Reply

  TechArena Community > Technology > Technology & Internet
Tags: , , , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to upload images using PHP??"
Thread Thread Starter Forum Replies Last Post
Unable to upload images to Facebook or SkyDrive with WINDOWS PHONE 7 Agavoli Portable Devices 6 28-09-2011 11:53 PM
Cannot upload images using Canon ZoomBrowser and CameraWindow JyotiT Windows Software 9 10-09-2011 10:31 PM
Need an FTP Client iPhone Application that is used to upload the images Stranger01 Portable Devices 3 21-12-2010 01:44 PM
Med-V Inability to upload Packed Image to Server: could not connect to Images Server 2Fast Operating Systems 5 23-08-2010 08:13 AM
How to upload images directly to Facebook from mobile phone Emma.J Portable Devices 2 19-05-2009 06:31 PM


All times are GMT +5.5. The time now is 09:32 AM.