473,811 Members | 3,640 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

$_FILES problem

I am trying to program a upload system.

The following code work very fine,

$file_name = $_FILES['uploadFile'. $x]['name'];
$size = filesize($file_ name);
$type = mime_content_ty pe($file_name);

However, when I change to

$file_name = $_FILES['uploadFile'. $x]['name'];
$size = $_FILES['uploadFile'. $x]['size'];
$type = $_FILES['uploadFile'. $x]['type'];

The program fail to give me any result.

Is there any problem happan in my code?

Thanks in advance for your advice.

Sep 7 '05 #1
3 5641
hi

don't rely on $_FILES['name']['type'] as php relies on the browser to
supply this.
here's a function from the contrib notes:

if (!function_exis ts('mime_conten t_type')) {
function mime_content_ty pe($f) {
$f = escapeshellarg( $f);
return trim( `file -bi $f` );
}
}

have you moved the uploaded file yet?
the path to the actual file is being kept in $_FILES['name']['tmp_name']
so your 1st piece of code shouldn't work.

Iced Milk Tea wrote:
I am trying to program a upload system.

The following code work very fine,

$file_name = $_FILES['uploadFile'. $x]['name'];
$size = filesize($file_ name);
$type = mime_content_ty pe($file_name);

However, when I change to

$file_name = $_FILES['uploadFile'. $x]['name'];
$size = $_FILES['uploadFile'. $x]['size'];
$type = $_FILES['uploadFile'. $x]['type'];

The program fail to give me any result.

Is there any problem happan in my code?

Thanks in advance for your advice.

Sep 7 '05 #2
Thanks a lot for your help!

I think bcoz' I haven't moved the file so problem arise.

But why does $_FILES['userfile']['name'] is working?

Barry 寫道:
hi

don't rely on $_FILES['name']['type'] as php relies on the browser to
supply this.
here's a function from the contrib notes:

if (!function_exis ts('mime_conten t_type')) {
function mime_content_ty pe($f) {
$f = escapeshellarg( $f);
return trim( `file -bi $f` );
}
}

have you moved the uploaded file yet?
the path to the actual file is being kept in $_FILES['name']['tmp_name']
so your 1st piece of code shouldn't work.


Sep 8 '05 #3
I don't really know, maybe you've got a file on the server with the same
name?

Iced Milk Tea wrote:
Thanks a lot for your help!

I think bcoz' I haven't moved the file so problem arise.

But why does $_FILES['userfile']['name'] is working?

Barry 寫道:

hi

don't rely on $_FILES['name']['type'] as php relies on the browser to
supply this.
here's a function from the contrib notes:

if (!function_exis ts('mime_conten t_type')) {
function mime_content_ty pe($f) {
$f = escapeshellarg( $f);
return trim( `file -bi $f` );
}
}

have you moved the uploaded file yet?
the path to the actual file is being kept in $_FILES['name']['tmp_name']
so your 1st piece of code shouldn't work.


Sep 8 '05 #4

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

Similar topics

0
7727
by: mrbog | last post by:
All I did was recompile my PHP 4.3.4 with the included GD and now my $_FILES is perpetually empty. My php app is identical, I haven't changed it at all since recompiling. I tried recompiling again without GD to fix the problem, to go back to what I had before, but $_FILES is always empty. I can't imagine that I'm doing something so out of the ordinary, and yet I'm unable to google for someone with the same problem. I am running...
1
2639
by: Bob Bedford | last post by:
I've a function asking for a $_FILES argument: function insertarticle($particle,......,$pUserID,$pOptions,$files){ in this function I do add the record and then save the files in a subdirectory specific on some datas. This function is used by my "insert" form, letting the user to select images files to upload with <FILE> html tag. The files to upload are then passed to the $files like this:...
6
2512
by: Shelly | last post by:
I have searched and have not gotten an understanding of $_FILES. I am trying to do an upload to a directory "tmpdir" on the server. I have a field defined as: File name: <input name="filename" type="file" id="filename"> In my PHP code I have (with diagnostics): echo "Will try to upload a file <br>"; echo "Tmp_Name: ".$_FILES."<br>";
8
3491
by: mpar612 | last post by:
Hello, I am a newbie to PHP, MySQL. I am trying to create a basic file upload form. I want to get that working and then I want to integrate that into a form that will rename the file and save it to a directory and store the path to the file in the db, in addition to storing other text from other fields in the form. Then I will get that path using PHP to display the image file in a browser. First things first, I'm having difficulty...
2
2865
by: Tom | last post by:
I've beat my head every way I can think of against this wall. Maybe someone here just knows the answer. I'm testing an upload class on my laptop WAMP server. When I run the test script, everything is fine. When I put together my own form and test uploading the same file, it fails because the $_FILES value is missing the trailing slash at the end of the temp dir name, so that the temp name looks like this: c:/wamp/tmpphp11.tmp
1
2583
by: Michael Rassinger | last post by:
Hi! I am facing the following problem: I have a PHP-script on page A that receives a file from an HTML-form. I need to immediately forward this file to another page B. On page A currently I forward the user (under certain circumstances) to page B using header ("location: page_b.php");
3
2250
by: skulkrinbait | last post by:
I've a HTML form that allows a user to specify the location to upload a file from: <p><label for = 'file'>Upload Graphics : <input type='file' name='imagefile' /></label></p> I then want to check if the user entered something or not as this isn't mandatory. Here's an excerpt of the relavent code: if (isset($_POST))
5
2583
by: Karl | last post by:
Hello again. I have a form for posting news articles. Form one is the "register" form. Then I go to the preview form were I can select edit or accept If I select edit, I got the "edit form" and if I select accept, I receive a message that say: The news article "headline" are posted into the database.
3
9388
Markus
by: Markus | last post by:
Ok, so i'm doing the multiple file upload thingymabob! I'm just playing around really... When i try to check the file type i simply get Array(). foreach ($_FILES as $_key => $_value) { echo $_value . " was uploaded successfully.<br />";
0
9726
marktang
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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9605
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,...
0
10384
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7667
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 presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6887
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();...
0
5553
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4338
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
2
3865
muto222
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.