try another color scheme:


Go Back   TECH6.0 > Get Techie > Programming > PHP/MySQL


Sending attached files in php !

This is a discussion on Sending attached files in php ! within the PHP/MySQL section, part of the Programming category; Could you please help realize the procedure of sending attached files in php. If it is possible, please, provide me ...

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 14-01-2009, 09:39 PM
No Avatar

Techie
 
Join Date: Jan 2009
Posts: 79
Anchor is on a distinguished road
Default Sending attached files in php !

Could you please help realize the procedure of sending attached files in php. If it is possible, please, provide me with ready code examples. Thanks in advance!
Reply With Quote
  #2  
Old 15-01-2009, 12:43 AM
webwizzy's Avatar

Administrator
 
Name: Vinayak
Join Date: Feb 2008
Location: India
Phone: Samsung Wave
Posts: 1,116
webwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nice
Send a message via Yahoo to webwizzy
Default

Sry, not able to get you! What are attached files in PHP and where do you want to send them to?
__________________
Always TAG and SHARE your threads
Submit your site to TECH6 Directory
TECH6 on Facebook - Like Us

Would you like to Link To Us | Support TECH6 by going Premium
Know more about me at Vinayaks.com | Follow TECH6 at Twitter


Reply With Quote
  #3  
Old 25-02-2009, 11:29 PM
TaL's Avatar
TaL TaL is offline

Moderator
 
Name: Steve
Join Date: Dec 2008
Location: Canada
Posts: 75
TaL will become famous soon enoughTaL will become famous soon enough
Default

I think that they are probably referring to uploading files to SQL as a blob type but same as you, until they respond I am not exactly sure what they are trying to accomplish
__________________
Go placidly amid the noise and haste, and remember what peace there may be in silence

The Desiderada
Reply With Quote
  #4  
Old 03-11-2011, 08:20 PM
No Avatar

Learner
 
Join Date: Oct 2011
Posts: 24
newsky is on a distinguished road
Default

See if this helps. To use this script, you need to create a folder named uploads where the uploaded files would be stored.
PHP Syntax (Toggle Plain Text)
<?php
$maxsize=28480; // Set the maximum upload size in bytes
if (!$_POST['submit']) {
//print_r($_FILES);
$error=" ";
// This will cause the rest of the process to be skipped
//and the upload form displays
}
if (!is_uploaded_file($_FILES['upload_file']['tmp_name']) AND
!isset($error)) {
$error = "<b>You must upload a file!</b><br /><br />";
unlink($_FILES['upload_file']['tmp_name']);
}
if ($_FILES['upload_file']['size'] > $maxsize AND !isset($error)) {
$error = "<b>Error, file must be less than $maxsize bytes.</b><br /><br />";
unlink($_FILES['upload_file']['tmp_name']);
}
if($_FILES['upload_file']['type'] != "image/gif" AND
$_FILES['upload_file']['type'] != "image/pjpeg" AND
$_FILES['upload_file']['type'] !="image/jpeg" AND !isset($error)) {
$error = "<b>You may only upload .gif or .jpeg files.<b><br /><br />";
unlink($_FILES['upload_file']['tmp_name']);
}
if (!isset($error)) {
move_uploaded_file($_FILES['upload_file']['tmp_name'],
"uploads/".$_FILES['upload_file']['name']);
print "Thank you for your upload.";
exit;
}
else
{
echo ("$error");
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PHP File Upload Script</title>
</head>

<body>
<form action="<?php echo(htmlspecialchars($_SERVER['PHP_SELF']))?>" method="post"
enctype="multipart/form-data">
Choose a file to upload:<br />
<input type="file" name="upload_file" size="50" />
<br />
<input type="submit" name="submit" value="Submit" />
<input type="reset" name="Reset" value="Reset" />
</form>
</body>
</html>

This bit of code moves the uploaded file from a temporary directory into the uploads directory:
PHP Syntax (Toggle Plain Text)
move_uploaded_file($_FILES['upload_file']['tmp_name'],
"uploads/".$_FILES['upload_file']['name']);

The MIME types included here are: .gif, .pjpeg and .jpeg but you may like to add more file formats.
This first line of the code defines the maximum file size:
PHP Syntax (Toggle Plain Text)
$maxsize=28480; // Set the maximum upload size in bytes
You can edit the size to suit your needs.
__________________
quang cao nha dat
Reply With Quote
Reply

Bookmarks


Thread Tools
Display Modes




All times are GMT +5.5. The time now is 01:11 AM.

Contact Us - Tech6.com - Link to Us - Advertise - Submit Site - Privacy Statement - TOS - Top