Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Email With File Attachements - How To Upload File To Server From Browser?


I have a PHP script that sends an email with attachment and works great when
provided the path to the file to send.

However this file needs to be on the same server as the script.

I want to develop a webpage where people can send attachments that are
stored on their local PC.

I know I can use the <input type="file" > HTML to generate a file box that
allows the user to navigate to a file on their PC and product a file path,
but how do I then upload this file onto file server to email out with my PHP
email script?

Is there an easy way to do this?

Or can I approach this problem from a completely different angle.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Multiple File Upload From Client Pc To Server Without Using <input Type="file"> Cont
I am working on a application which requires me to upload the contents of all the files from a particular folder in clent pc to the server.

In my code i just want to mention the folder name which may contain any number of files.Folder name will always be fixed.
I dont want to use <input type=file > control.

Is there any way i can achieve this using FTP or any other way in PHP.Any help will be greatly appreciated.

File($url) Problem - Fulling Server Into Thinking You're A Web Browser
I want to try and grab the HTML of a web page, but I have a little
problem - the web designer/developer of the page! He made it one of
those pages that displays "Please update your browser. This web site
does not support Netscape Naivagator version 1.234" if it "thinks"
your browser isn't up to par.

When I try to use PHP file($URL) function to grab the HTML, my request
doesn't have any header information informing the server what my web
browser is, so I get this message:

Is there any way to fool it my providing bogus meta/header information
in my request? Is there another solution?

Upload File Into Server.
I want to upload image from browser to server. Exp: Your customer can upload new product in our website. What can I do?

How To Upload A File To A Ftp Server
I need a script which can upload a file to a ftp server that requires a password. does anyone have a quick solution.

Upload File To Other Server
I have 2 Servers running.

1 for images, 1 for php docs.

I have an image upload script.. both servers are under the same domain ie.

http://www1.mydomain.com
http://www2.mydomain.com

Is there anyway to resize my images etc on the php server and then directly upload the files to the other server without having to ftp it and then delete it from the php server?

Upload Image File Onto Server
I've looked at some posts on file uploading, but none have helped me in figuring out why this isnt' working. Here's what I have:

Where To Find File Upload Tmp_name On Server?
Can someone tell me where to find tmp_name on my server; the place where temporary file uploads are stored?

Email Notification When A Server File Change?
I'm looking for an script that will notify me by email or log file when any server file change.

Upload File To Server As '[username]' As Opposed To 'www-data'
I have an upload script that works great... except that it's on a linux server, and the owner of the uploaded file is not me, but rather "www-data"

This isn't a major problem (that i see), but it may be, and it also keeps me from having full control over said file.

Is there a way to get an upload script to specify a user as the owner?

File Upload Issue - Unable To Upload A Large File
I am using PHP Version 4.4.3 under Linux/Apachie to upload files.
The PHP.ini upload_max_filesize is 2M, which I need to override this
in the HTML (see below). I changed the MAX_FILE_SIZE to 4,000,000
but the system only accepts files less than 2M.

Is the override wrong, do I need to raise the limit in the PHP.ini
file, or is the Apachie issue.

<form name="upload" action="admin.php" method="post"
enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="4000000">

Server To Server File Transefer Script, Getting Wrong File Size
Any help on this is most appreciated. I have created a function to download a file. It seems to work except the file sizes differ greatly. I start off downloading a 5mb .zip file and end up with a 2mb .zip file on the initiating host. Thanks for any advice on this.

function get_http_file ($host_url, $http_file)
{
global $host_url, $http_file;

$fp = fopen("$host_url/$http_file","rb");

while(!feof($fp))
{
$my_file .= fgets($fp, 4096);
}

$fptmp = fopen("/tmp/$http_file","wb");
fputs($fptmp,$my_file);

fclose($fp);
fclose($fptmp);

if (file_exists("/tmp/$http_file"))
{
$result_code = 1;
}
else
{
$result_code = 0;
}

return $result_code;

PHP File Upload Unexpected Error - File Too Large?
I have a short basic script to upload files. It works fine with small files,
but with longer files it gets stuck.

Here's the fragment, the input file is loaded in "$file" from an HTML form
as usual.

....
$img_str = fread(fopen($file, "r"), filesize($file));
$data = addslashes($img_str);
// --------------------- up to here the execution is correct and fast (<1
second)

$sql="INSERT INTO $table (".
" file_name,".
" file_type,".
" file_size,".
" bin_data)".
" VALUES (".
" '$file_name',".
" '$file_type',".
" '$file_size',".
" '$data')";
// --------------------- it gets stuck
here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
mysql_query($sql) or die ("SQL error ..$sql");

I have already set the php.ini variables as follows:
memory_limit = 16M
upload_max_filesize = 6M

I also checked the execution time to max_execution_time = 300 (even though I
don't believe it should be necessary).
The server is a P4 1.8 GHz, 256MB RAM

File Upload Script - Testing For Existence Of File
i'm having a strange problem when processing some form data. I just want to validate that required fields have been populated, then, if an image has been uploaded, i want to ensure that a description of the image has been provided (for alt tag purposes) before processing the data.

For some reason, when a file hasn't been attached, my script interprets it otherwise and prompts the user for the alt tag. I've not come across this problem before, there's a good chance i've done something idiotic but i just can't see it Code:

Warning: File(): URL File-access Is Disabled In The Server Configuration
Does any one know how to work around this error on a web site?

Warning: file(): URL file-access is disabled in the server configuration ...

Download File And Delete File From Server With One Button Click
I want the user to be able to download a CSV file and delete the file from the server all with the click of a button.  Currently, in firefox, it will just display the CSV and not delete it. In IE, it will download the CSV and not delete it. Code:

File Upload - Directory Is Writable, File Is Not
I'm writing a script to upload images along with articles to a
directory on the server. I'm developing it offline on my WinXP and
Apache 1.3.x laptop and it's working great, but when I move the script
to the server, I get write errors when the file attempts to upload.

So I set up a test script (included below) to test the directory
structures all the way up to the file, and every directory appears to
be writable, yet I can't write to the test file. I keep seeing
suggestions to set the open_basedir directive in the php.ini file to
solve this, but it's hasn't worked yet. Can anyone suggest what I can
try to get the uploads working?

<?php

$filename = 'images/articles/test.txt'
$somecontent = "Add this to the file";

......

File Upload Handling (file Types Etc.)
I have two questions. First, how can I control what files a user uploads? I can, of course, check the extensions but they can't always be trusted. Can I check the mime-types somehow? Second, is there a way I can set the "available formats" in the file upload dialog box?

File Upload Works But Only For Empty File
I can upload a file as long as it is empty (thanks Hendri Kurniawan).
I do not know where to look.

Can someone help me understand what I need to do to upload a small image.
http://chops.novatrope.com/game/test/upload_file3.php

Here is some more info http://chops.novatrope.com/info.php

I Can Not Get File Uploads To Show Up When I Upload A File
I've a form that starts off like this:

<form method="post" action="profile.php?
id=5&formName=my_story_edit.htm" enctype="multipart/form-data">

<p>Email address:<br />
<input type="text" name="totalFormInputs[users][5][email_address]"
value="lawrence@krubner.com" /></p>

<p>Zip code:<br />
<input type="text" name="totalFormInputs[users][5][zip_code]"
value="22902" /></p>

<p>Personal image:<br />
<input type="file" name="totalFormInputs[users][5][upload_file]" /></
p>

Oddly enough, the "upload_file" has suddenly disappeared from the
uploaded array. When I hit $totalFormInputs with print_r, this is what
I get:

Array
(
[users] =Array
(
[5] =Array
(
[description] =I grew up in New Jersey.
[email_address] =lawrence@krubner.com
[zip_code] =22902
[time] =1187380627
)

)

)

Display File Type Of Upload File
How do I display the file type of an uploaded file, in order to find out what mime type to use?

Script For Grabbing An Xml Rss Feed File Into My Server As Xml File Too
How do I copy using a php or cgi script a remote xml rss feed into my server?

I.E the rss feed:

http://www.lanacion.com.ar/herramie...ex.asp?origen=2

Due to restrictions in flash player 7 I need to load a remote xml rss feed.
I am using load.xml( http://www....

but in that way doesn´t work

The only way that works is when the rss xml feed is placed on my server. I could upload manually the xml rss feed but I need a php script to be called from flash and then parsed. What I need is the script to make that remote xml being "local" to my flash movie.

Trying other stuff Ive found on forums about "proxy scripting" but that only works if you are using flash player 6, flash player 7 even don´t allow redirection scripts at all.

Deleting A File From Server Through A File List
I've been having trouble with this for a while. Ages ago I made an upload script that lets you upload to files/upload/ and then once you upload it, a piece of PHP will show the files in that folder.

In the admin section of my page i'm trying to find a way to delete the files off the server without having to dig into the FTP and do it manually.
Are you able to do that with PHP? Code:

Upload File Gives A Blank File Name
I am having trouble with an upload script. Searched the forum but still couldn't fix it.
Here is the code: PHP Code:

Upload Jpg With Ftp -fine, Upload With Php Wrong File Type!
i've scripted a file uploader, about as basic as you can get, and works on all accounts except that it tells me every single jpg is the wrong file type - BUT i can ftp all these same images and they all behave correctly.

echo filetype($type_file);

//got this warning
Warning: filetype() [function.filetype]: Lstat failed for image/pjpeg
any ideas?

Opening File In Browser
I'm working on a script that accesses objects stored in Amazon S3. I'm new to web development and am sure I'm missing something fundamental about opening files in a browser. This code will print a URL that, when clicked on, will open pictures in the bowser or ask which program you want to use open a given file coming from S3: Code:

Browser.history And Log File
I am very beginner with PHP. I have an Apache PHP enabled
webserver and want to know from where users are coming from.
Understand I want the last surfer's browser visited url.
I imagine I can do this with some kind of interraction
between 2 scripts : one client side, one server side.
The client one send the URL and the server one write it
in the right log file.
I have no idea of how to do this nor with principle nor
with syntax ...
Can somebody help with a few lines *working* example?

Returning A File To Browser Via Php
I need to be able to "send, or stream" a file to the client browser
using PHP code. This is the scenario.

The user clicks a link on a page (after logging in to the site). I
need to have my PHP code return a document -a Word document file, let's
say - to the browser for display. However, the document is not in the
public WWW folder. For security reasons, it is on another drive on the
same machine.
I need to have the php code return the file to the browser so that I
can wrap security code around this process.



Opening Mht File In The Browser
I have an .mht files saved above the public root and i need php to open it and display in the browser as a regular page. Is there any way to do it. I tried something like:

header("Content-Type: text/html");
include "/usr/home/sites/documents/doc_39.mht";and it wouldn't work. It gives me just a huge number of characters.

Including File And Output To Browser
I am not sure I understand the rules as to what exactly gets output to a
browser and when. If I include a text only file or an html file, these will
show up in the browser regardless of where in the script they are included.

Execute Exe File From Php Code Through Browser
step 1.
testcommand.php
----------------------
$cm='p4 dirs //seabu/*'
$handle = popen($cm, 'r');
echo "'$handle' " . gettype($handle) . "
";
$read = fread($handle, 4096);
$p=fopen("c:wwwshowcasekamal.txt","");
fwrite($p,$read);
echo $read;
pclose($handle);

step 2.
i compiled this testcommand.php file with bamcompile and i created exe called testcommand.exe.

step3.
callexefile.php
----------------
exec("c:wwwshowcase estcommand.exe");

then i executed this callexefile.php thorugh browser, but its not calling the testcommand.exe file. how to solve this?

BOF In The Included File Shows Up In The Browser
I have an UTF-8 PHP file which generates HTML
Then I cut the beginning of that file, pasted into another UTF-8 file ind
included this second file into the first one.
After that the whole page moved down about one libe leaving a gap at the top
of the browser window.

Viewing the resulting code of the first file via VIEW-Source, I and see a
square inserted before the included file.
This does not show if I open the included file with a Unicode supporting
text editor. A non-unicode editos shows i>?
at the beginning of the file which, I understand, is BOF.
So the problem is that the browser sees the second BOF and displays it as a
small square in a separate line

Disconnecting Client Browser From Php File
I'd like to initiate a php script using a standard httpd request, but
then allow the client browser to disconnect without terminating the
script. Freeing up the browser to access other functions on the site.

Whilst a combination of connection_timeout() and ignore_user_abort()
can stop the script from terminating when the client calls
termination, i'd like to terminate the clients connection rather than
having to wait for the client to do it.



Playing Wav Audio File In The Browser
Is there a simple way to embed a wav file that shows the stop and play button, and also the progress bar without the users being able to download the wav file when they right-click on the player??

PHP / Javascript File Browser / Downloader
Anyone know of a good, ready-made (FREE) PHP file browser (possibly with Javascript/"AJAX" to make navigation smoother)?

I need it to operate like this

/mysite.com/httpdocs/filebrowser.php <- file users hit (i.e. www.mysite.com/filebrowser.php)
/mysite.com/files/
/mysite.com/files/A/fileone.tiff
/mysite.com/files/A/filetwo.tiff
/mysite.com/files/B/filethree.tiff

User sees:
A
B

They click "A" and see:
fileone.tiff
filetwo.tiff

So the files themselves need to NOT be web accessible. I need PHP to load the directory structures, allow users to "browse" by clicking a folder to view sub-folders, and ultimately click the file and load it in the browser for the user.  If it helps any, these will be .tiff files.

Maybe a PHP download script exists that does this? You know, that masks the actual file URL to prevent direct-linking?

Test Server To Live Server - Best Way Of Handling Different File Paths In Scripts?
I have taken over someone else's PHP code and am quite new to PHP. I made
some changes and have implemented them to a live environment fine so far.

However, I now want to setup a test environment. All the PHP scripts start
with a few lines of:

require_once "library file at specific location on server"

and when I move them from the test location to live location I have to
manually apply the changes to each script to reflect the different paths for
each server.

I was thinking of writing a small script that is contained within the same
folder as any folder that contains scripts that actually calls another
require for that server .

E.g.
Have script do_something.php which I am developing regularly.
On live server it starts with
require_once "/home/live/phplib/library.php";
On test server
require_once "/home/test/phplib/library.php";

Currently I apply a manual change this (via global change or whatever) when
moving from Test to Live
However, I might just change all requires to:
require_once "./require.php";

And then have a server specific version of require.php that contains the
necessary requires for the particular server on which it resides.

This way I can just change all the scripts to just require the require.php
file in the same folder as itself. The actual PHP scripts where I do most of
my updates need no changes whether on live or test servers.

I just wanted to know if there was a better way of doing it then this. I
know nothing about directives in PHP or if there was a way of determining
the current server name and then calling different require commands
appropriately.

Header() Question: Viewing A File On Browser
I got some problem to display a file to a client browser. Here is my code:

$mimeType = "text/plain";
$filename = "abc.txt";
$fileContent = "Hello world";

header("Content-disposition: filename=" . $filename);
header("Content-type: " . $mimeType);
header("Connection: close");
header("Expires: 0");
echo $fileContent;
exit();

I need to get it work in IE 5.x, please help.

PHP File Downloading Instead Of Showing Results In Browser.
I'm sure all the guru's know this one, but I cannot find it. I just
installed Luinx. I configured Apache and got everything up and
running.

When I do my PHP test, it asks me to download the file, rather than
displaying the info on the screen.

Now, I added the following lines to the httpd.conf:

LoadModule php4_module /usr/lib/httpd/modules/libphp4.so

AddType application/x-httpd-php .php .php3 .php4 .phtml
AddType application/x-httpd-php-source .phps

DirectoryIndex index.html index.php index.html.var

And I restarted the server........no good. It displays HTML documents,
but not PHP documents.

Destroying File When Browser Sess. Ends
I have a code that reads database output and writes it to a $temp file. It then uses the temp file on subsequent loads of the script instead of querying the database again. I would like to know if there is a way to delete the $temp file when the user ends the browser session.

Dont Want The File Names In The Browser Address Field
Is there a way in PHP where the file name do not appear in the browser address field.

eg. the url of a file is : http://www.somedomain.com/somepage.php.

but when a link to this page is clicked, only http://www.somedomain.com should show up in the browser address field.

Read From A Text File, Output To Browser In Japanese
I am trying to store data in a text file and output it to the browser
using PHP. All very easy - if I was using English! the problem is, I
want to use Japanese and I'm finding it a tad difficult to get PHP to
understand. I have two files, a text file containing data to display
and a php file with a script to display the data. I can get the
contents of a text file displayed in English, no problemo, but in
Japanese, it's another story...

All the correct settings are enabled in the php.ini file for Japanese
language support (mb_string, input_encoding, output_encoding settings
etc..etc..) even if I save the text file, to be read from, in
Shift_JIS encoding - I still can't get it to display normally!

here's the script I'm using to read the text file :

<?
$filename="test.txt";
$fp = fopen($filename,'r');
while($line=fgets($fp))
{

//output text file line
print $line."<br>";

}
fclose($fp);
?>

How To Avoid The Cron File Being Overwritten When The Browser Is Submitting The Task
How to avoid the cron file being overwritten when the browser is submitting the task to a cron file at any moment?


I am writing the PHP that allow browser to submit task with definite cron file name.

If in php program I do something like:

$command="crontab $task1";
exec($command);

Browser Unable To Send Another Request While It's Downloading A File From PHP Page.
While I am downloading a mp3 file from php page, browser freezes and
is not able to send any request and get the response using ajax until
the file gets completely downloaded. As soon as the file downloading
finishes, the browser gets all the responses it is waiting for (which
are sent after the file download starts)....

Email A File As The Body Of Email
i have a file....:

<html>
..........
........
.........
<?php echo $USer_Name; ?>
.........
.........
........
</html>

assuming its called email.php, how would i send that file as the body of an email using mail(), coudl i do it.  and if so, how..

File Upload????
I need to upload mp3 files to either a database or a file. If it is uploaded to a directory, then I need somehow to put the address of the file into a database, can someone please guide me in this.

File Upload

I've tried to write a script to upload files. I'm using redhat and php3. I'm receiving the followind error:

Warning: Unable to create '/usr/local/apache/htdocs/rex/admin/test/html40.zip': Permission denied in /usr/local/apache/htdocs/rex/admin/test/test.php3 on line 40

What rights should i set ? I've tried all the combinations for owners and rights URL but it doesn't work....

File Upload
Here is the situation. I have a 'Comments' box on a HTML page where a user will enter some comments. Once the submit button is pressed, the comments show up on a PHTML page(summary).
I am now trying to place a File Upload option on the HTML page also, whereby I want the user to be able to enter comments, select a File, then only press 1 Submit button that will then show both the Comments and the File on the PHTML page.

File Upload
Hi,

I am writing an admin section for estate agent website and want only the authorised admin user(s) to be able to upload images to upload folder. I already implemented admin login through session variables. Is this enough or do you need to secure the upload folder as well?

How should you check that PHP has the correct rights
to write files to the secured folder you want to upload files/images to.

File Upload
I'm trying to get a file upload to work and it's not happening. Here's my
form code...

File Upload
I am using php3 and am trying to upload a file with the following code. When i try to upload it sets $filename to /var/tmp/phpDAA...

I don't know why it's doing this. Anyone have any ideas on how to fix this? I do not have access to / my private directory is in /opt2/company_name/ ,more info code:


Copyright © 2005-08 www.BigResource.com, All rights reserved