473,472 Members | 1,719 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 4499
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
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
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
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
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
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
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
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
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
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
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
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...
1
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...
0
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...
1
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
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.