| |||||||
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 ...
![]() |
|
| | LinkBack | Thread Tools | Display Modes |
|
#1
| ||||
| ||||
|
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!
|
|
#2
| ||||
| ||||
|
Sry, not able to get you! What are attached files in PHP and where do you want to send them to?
__________________ Would you like to Link To Us | Support TECH6 by going Premium Know more about me at Vinayaks.com | Follow TECH6 at Twitter |
|
#3
| ||||
| ||||
|
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 |
|
#4
| ||||
| ||||
|
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 |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |