473,385 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

$_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_type($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 5615
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_exists('mime_content_type')) {
function mime_content_type($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_type($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_exists('mime_content_type')) {
function mime_content_type($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_exists('mime_content_type')) {
function mime_content_type($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
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...
1
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...
6
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...
8
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...
2
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,...
1
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...
3
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...
5
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"...
3
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) {...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
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,...

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.