473,740 Members | 6,250 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

error :Email with attachment:move file upload :failed to open stream

2 New Member
I have a main form for inputing the (to/from/mesg/file) with the following code:-
<td><input type="text" name="to" size="50"

value="pras_san dilya@rediffmai l.com"></td>
<td><input type="text" name="from" size="50"></td>
<td><input type="text" name="subject"

<textarea cols="60" rows="5" name="message"
>Enter Your queries here</textarea>


action="http://www.urovisionho spital.com/ematt.php"

id="upload" ENCTYPE="multip art/form-data"

Browse File<input type="file" id="abc" name="abc">
<input type="submit" name="upload" value="SEND


<input type="reset" value="Reset the form">


then I use theabove form to send the email with attachment: The next code first uploads to tmp dir on server and then sends the mail from the server.:-
$message ="file uploaded";

$temp_name = $_FILES['abc']['tmp_name'];
$file_name = $_FILES['abc']['name'];
$file_type = $_FILES['abc']['type'];
$file_size = $_FILES['abc']['size'];
$result = $_FILES['abc']['error'];

$upload_dir=$up Dir . $temp_name;

//File Name Check
if ( $file_name =="") {
$message = "Invalid File Name Specified";
return $message;
//File Size Check
else if ( $file_size > 500000) {
$message = "The file size is over 500K.";
return $message;
//File Type Check
else if ( $file_type == "text/plain" ) {
$message = "Sorry, You cannot upload any script

file" ;
return $message;

if(move_uploade d_file($_FILES['abc']['tmp_name'],$u


print $message;



$to = $_POST["to"];
$from = $_POST["from"];
$subject = $_POST["Subject"];

$fileatt = $upload_dir;

$fileatttype = "applicatio n/octet-stream";
$start= strrpos($fileat t, '/') == -1 ?

strrpos($fileat t, '//') : strrpos($fileat t, '/')+1;
$fileatt_name = substr($fileatt , $start,

strlen($fileatt )); // Filename that will be used

for the file as the attachment

$headers = "From: $from";



$file = fopen( $fileatt, 'rb' );
$data = fread( $file, filesize( $fileatt )

fclose( $file );


$semi_rand = md5( time() );
$mime_boundary =

"==Multipart_Bo undary_x{$semi_ rand}x";

$headers .= "\nMIME-Version: 1.0\n" .

multipart/mixed;\n" .

boundary=\"{$mi me_boundary}\"" ;

$message = "This is a multi-part message in

MIME format.\n\n" .
"--{$mime_boundary }\n" .
"Content-Type: text/plain;

charset=\"iso-8859-1\"\n" .

7bit\n\n" .
$message . "\n\n";

$data = chunk_split( base64_encode( $data )


$message .= "--{$mime_boundary }\n" .
"Content-Type: {$fileatttype}; \n"

" name=\"{$fileat tname}\"\n" .

attachment;\n" .
" filename=\"{$fi leattname}\"\n" .

base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary }--\n";



if( mail( $to, $subject, $message, $headers

) ) {

echo "<p>The email was sent.</p>";

else {

echo "<p>There was an error sending the




I get the error msg:move file upload /failed to open stream.
Kindly help in the coding.
Apr 28 '07 #1
0 2489

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

Similar topics

by: BT | last post by:
Hi, I am trying to install php-mysql-4.0.6-7.i386.rpm(to get php to work with mysql as suggested for my earlier error). I get the following error for rpm -i php-mysql-4.0.6-7.i386.rpm. Error failed dependecies : libmysqlclient.so.10 is needed is needed by php-mysql-4.0.6-7.
by: Josema | last post by:
Hi to all, I have a webform.aspx and inside i have a dropdown list with autopostback and a place holder... Depending of the selected index that the user selects in the dropdownlist i load a usercontrol into the place holder... i dont know why im getting this error:
by: Zameer | last post by:
Hi All, I want to know how i can add attachment file to form for a particular user.Its like user fills his information on form and he can add an attachment file if he wants.And later when you click on the User.His information along with the attachment should be displayed.
by: Sebastian Mark | last post by:
Did anyone got error like that? When I'm trying to Update WebReference in my project this is an error I'm getting "Custom tool error: Failed to generate dataset. Undefined data type: 'anyType'." The anyType is really a GUID. The problem is its working fine on my friends computer (they get string insted of anyType) and it complies fine. I even tried to reinstall VS.NET 2003 but no positive result. Does anyone had that problem before?
by: Paul Urbanus | last post by:
Hi, I'm a perl hack and want to distribute a windows executable of one of my scripts. When I invoke the perl compiler by using perlcc, I get the following error. perlcc.bat: Can't unlink error file pccrYVGS If I try multiple times, the error is the same but the filename changes.
by: ASP Developer | last post by:
I recently changed the path of a virtual directory on my computer. After doing this I got an error in my solution stating that the web application could not be found. So I then copied all of the files from the old location to the new location and the solution can now find the web application. However, now when I try to use "get latest version" I get the error: Unexpected error encountered. It is recommend that you restart the...
by: cainwebdesign | last post by:
php newbie needs help Warning: file(http://shop1.outpost.com/product/5053975) : failed to open stream: HTTP request failed! HTTP/1.1 404 Not Foundin I am just trying to put some code around this to trap it.
by: =?Utf-8?B?VmFxdWFy?= | last post by:
Hi, Past few days I see following errors in Event Log after which few ASP scripts stopped working (or part of it's functionality - not very sure which one). "Error: File /trxweb/trxweb.asp Unexpected error. A trappable error (E06D7363) occurred in an external object. The script cannot continue running.." Source : Active Server Pages
by: Justin | last post by:
When executing the command : db2fm -D I received the error: Failed to find the default instance. Environment variable $DB2INSTANCE not set properly. What is the best approach from here - Using option -i for instance ?
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
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: 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: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.