View Full Version : upload file in php..
ff123
04-19-2009, 10:44 AM
hey im searching for a php code to upload file system by user. I found some on internet but im including that upload file within Contact Us form so can i include that uploading thing within the Php page i already have to send email
borikenMedia
04-19-2009, 02:02 PM
chek this one should do it.
http://us.php.net/manual/en/features.file-upload.php#72064
ff123
04-20-2009, 01:40 AM
chek this one should do it.
http://us.php.net/manual/en/features.file-upload.php#72064
i cant figure it out.. any help?
borikenMedia
04-20-2009, 02:27 AM
ur looking for a contact form with an attachment tool on it?
to see if i can help u out.
bluewalrus
04-20-2009, 04:13 AM
Maybe this.... http://www.webcheatsheet.com/PHP/send_email_text_html_attachment.php#html
ff123
04-20-2009, 04:29 AM
ur looking for a contact form with an attachment tool on it?
to see if i can help u out.
I already have contact form working just wanted to add attachment with it...
bluewalrus
04-20-2009, 04:59 AM
its not gonna be one line. use the code from that and modify your current file.
ff123
04-20-2009, 05:34 AM
its not gonna be one line. use the code from that and modify your current file.
hmm never did this attachment before and i dont even want to mysql in this attachment here is the code in php and also tell me what to add in html file as well.
if(isset($_POST['submit'])) {
$to = "email";
$clientid = "13001";
$mail = "1";
$subject = $_POST['subject'];
$message = $_POST['message'];
$message1 = $_POST['message1'];
$body = "E-Mail: $mail\n Client Id: $clientid\n Comment:\n $message\n Suggestion:\n $message1";
echo "Email Sent";
mail($to, $subject, $body, "From: $mail");
} else {
echo "invalid!";
}
name the file as upfile.php
<html>
<body>
<form enctype="multipart/form-data" action="upload_file.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
</body>
</html>
//name the file as upload_file.php
<?php
$target_path = "uploads/";
echo $target_path."<br>";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
?>
first you create a folder and name it as upload and this folder should be in the folder where the the above two programs is in ,and execute the program upfile.php
bye
ff123
04-20-2009, 06:25 AM
can I add this in my php code which i posted above
hai
the main goal is to upload the file ,for that purpose it is enough to use my code.but i cant understood your problem. do you want to upload the contactus page?
then by executing upfile.php you should browse the location of contactus page.
hai,
I cant understood ur problem
the main goal is to uplaod file.for that purpose it is enough to use my code .
first executing the upfile.php from that you can browse the contactus page
ff123
04-20-2009, 07:40 AM
I have a CONTACT US PAGE... which uses PHP TO send EMAIL to me, i want to add an UPLOAD FILE field WITHIN THAT PHP file THAT im already using... do you understand now?
then please put the action from contactus page to upfile.php
or
you can also use the code with in contactus page by using include("upfile.php");
or
do you want to insert that code into your contactus page then copy the code and put in contactus page and use the text field names same means i used uploadedfile in upfile.php and it occurs 3 times in upload_file.php.if u want to change it then replace it in 3places.
ff123
04-20-2009, 04:30 PM
hi i made this now and its not uploading..
if(isset($_POST['submit'])) {
$target_path = "uploads/";
echo $target_path."<br>";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
$to = "email";
$clientid = "13001";
$mail = "1";
$subject = $_POST['subject'];
$message = $_POST['message'];
$message1 = $_POST['message1'];
$body = "E-Mail: $mail\n Client Id: $clientid\n Comment:\n $message\n Suggestion:\n $message1";
echo "Email Sent";
mail($to, $subject, $body, "From: $mail");
} else {
echo "invalid!";
}
ff123
04-21-2009, 07:39 AM
name the file as upfile.php
<html>
<body>
<form enctype="multipart/form-data" action="upload_file.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
</body>
</html>
//name the file as upload_file.php
<?php
$target_path = "uploads/";
echo $target_path."<br>";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
?>
first you create a folder and name it as upload and this folder should be in the folder where the the above two programs is in ,and execute the program upfile.php
bye
Your program does not work well, I tried it and its not uploading and giving erorr that please try again..
ff123
04-21-2009, 03:37 PM
please can anyone help me in this? i tried other scripts as well and no one is working..
ff123
04-24-2009, 10:19 AM
bump...
hey you put in action in the form tag to upload_file.php
i specied above action="upfile.php " not to upload_file.php in contactus.php
<form enctype="multipart/form-data" action="upload_file.php" method="POST">
ff123
04-25-2009, 01:36 AM
hey you put in action in the form tag to upload_file.php
i specied above action="upfile.php " not to upload_file.php in contactus.php
<form enctype="multipart/form-data" action="upload_file.php" method="POST">
Ive tried the exact code that you have given me before.. that is not working either.. what could be wrong?
ff123
04-27-2009, 12:54 AM
bump...
ff123
04-28-2009, 12:36 PM
so no one is helping?
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.