473,491 Members | 2,430 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

file upload not showing up in /tmp linux

Jim
I'm having huge problems with a web server not putting the uploaded
file in the /tmp

here is my code can some one please point me in the right
direction?I'm thinking i've
done something with wrong with apache but can't find out what.

---- up.html ----
<HTML><BODY>
<FORM method="POST" enctype="multipart/form-data" action="./up.php">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000000">
<input type=file name=fupload>
<INPUT type="submit">
</FORM>
</BODY>
</HTML>
---- up.html ----
---- up.php ----
<HTML><BODY>
<?php
echo "main hi $fupload<BR>";
if( isset($fupload)){
echo "isset found hi $fupload_name<BR>";
}
?>
</BODY>
</HTML>
---- up.html ----
---- output from a file uploaded of 120k----

<HTML><BODY>
main hi <BR></BODY>
</HTML>
---- output ----
Jul 16 '05 #1
2 4500
Hi Jim,

How PHP handle's uploaded files is quite different to normal variable
submission (which isn't mentioned in the PHP documentation very well).

$fupload won't be a variable containing the contents of the file you've
uploaded, but an array of file information in the global $_FILES array
(I don’t code PHP with global variables on).

So for:

<FORM method="POST" enctype="multipart/form-data" action="./up.php">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000000">
<input type="file" name="fupload">
<INPUT type="submit">
</form>

To check if a person has selected a file, and submitted, then print the
file contents out, you would require the following PHP (for example).

<?php

//
// Check if a file has attached ('none' needed for IE compatability)
//
if ( (!empty($_FILES['fupload']['tmp_name']) ) &&
$_FILES['fupload']['tmp_name'] != 'none' )
{

$file_content = addslashes(fread(fopen($_FILES['fupload']['tmp_name'],
'r'), filesize($_FILES['fupload']['tmp_name']) )); // Read File

echo $file_content; // Echo it

}
else
{
echo 'No file was submitted';
}

?>

Btw, $_FILES['fupload']['tmp_name'] returns the name/path of the file as
it's temporarily stored on the servers FS, so having a

echo $_FILES['fupload']['tmp_name'];

would return something like

/tmp/php8329x9

Ovbiously in the $_FILES['fupload'], the 'fupload' corresponds to the
name of the form file bit in your form, so you could have multiple
uploads on the one form with $_FILES['fuploadwhatever'],
$_FILES['fupload3'] etc.. corresponding to a:

<input type="file" name="fupload3">
<input type="file" name="fuploadwhatever">
Hope this helps.
Grant
Jim wrote:
I'm having huge problems with a web server not putting the uploaded
file in the /tmp

here is my code can some one please point me in the right
direction?I'm thinking i've
done something with wrong with apache but can't find out what.

---- up.html ----
<HTML><BODY>
<FORM method="POST" enctype="multipart/form-data" action="./up.php">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000000">
<input type=file name=fupload>
<INPUT type="submit">
</FORM>
</BODY>
</HTML>
---- up.html ----
---- up.php ----
<HTML><BODY>
<?php
echo "main hi $fupload<BR>";
if( isset($fupload)){
echo "isset found hi $fupload_name<BR>";
}
?>
</BODY>
</HTML>
---- up.html ----
---- output from a file uploaded of 120k----

<HTML><BODY>
main hi <BR></BODY>
</HTML>
---- output ----


Jul 16 '05 #2
Jim
Absolutly Awesome thanks a ton.
Jul 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2497
by: Atz | last post by:
Hi to all ! This is the working, completed PHP script for file upload. The only problem is: wenn i send file and when the file is upload on the server, the file name ( orginal file name is...
1
13111
by: david | last post by:
Hi there, Does anybody know of some restriction that stops the apache user on doing a dos2unix on a file upload from php? I'm getting 'permission denied' on some temp file that it tries to...
5
1361
by: The Nordic One | last post by:
I was trying to upload a small 22K JPEG image from my computer here at work, which is Linux Red Hat 7.3, to a website (www.picture.com) file (ASP) that is within a Windows (I believe NT but not...
1
5535
by: Pamela Chatterjee | last post by:
In my project I am uploading file using File control. After browsing file user needs to select other values from DropdownList to determine uploading path. After selection in couple of drop down...
4
6823
by: G0ng | last post by:
Hello. I have a form with two input file fields for uploading file: <form name="mynews" action="news.php?action=update&add=<?php print $id;?>" method="post" enctype="multipart/form-data"> ...
5
2281
by: LtCommander | last post by:
Hello all, 1. I am a little new to ASP.NET, so please bear with me. 2. I am trying to create a very simple website which requires an upload box (end user file sizes may be anywhere between 1MB...
2
1276
by: achal | last post by:
hi, my file upload is working fine in my local machine,but not in remote system it is showing errors like in we.config <custom errors mode="off"> or <custom error mode="remoteonly"> i need...
3
1633
by: imrantbd | last post by:
Hi this is Imran, I am facing some problem to track file upload time in a linux hosting. I used filectime / filemtime to track date. But I get the time stamp of locally file creation time.I can...
6
9232
dmjpro
by: dmjpro | last post by:
Have a look at my HTML Code and my Java code. I m trying to see the total contents when a form is submitted with enctype=multipart/form-data. <html> <head> <title>Simple File Upload...
2
7625
by: hotflash | last post by:
Hi All, I found the best pure ASP code to upload a file to either server and/or MS Access Database. It works fine for me however, there is one thing that I don't like and have tried to fix but...
0
6978
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...
0
7154
Oralloy
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,...
0
7360
tracyyun
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...
0
5451
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4881
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3076
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1392
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 ...
1
633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
280
bsmnconsultancy
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...

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.