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






SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Upload File Type Issue


When uploading excel(.xls) files, the file type is saved in the database as text/plain type. Why is this? If I upload pdf/doc files the filetype is correctly stored as pdf/doc type. Code:




View Complete Forum Thread with Replies
Sponsored Links:

Related Messages:
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">

View Replies !   View Related
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?

View Replies !   View Related
File Upload :: 'wrong File Type' On Another Server
doing a simple image (jpeg) upload to a directory. Have a script which works fine on one server but comes up with 'wrong file type' on another server. The server that works has php5 installed, the other is 4.2.2 but I am sure what I have should work on both.

PHP Code: ......

View Replies !   View Related
File Upload NOT Using HTML Input Type=file
in an earlier post on the javascript forum i was talking about a small program i'm writing to allow file uploads through the http protocol that look and function similar to a ftp client.

I have made some nice progress on this project and am able to return the FSO collection from the client pc. this allows me to list of directories on the page so users can select multiple files to upload at once or even entire directories. Code:

View Replies !   View Related
Upload File Issue
First of all I am rather new into PHP. I use php 5 and I am putting
together a web site for a local association I belong too.
Most of the site is okay, except for this problem :

I need to be able for the member of the site to upload files (gif, jpg
or pdf). After reading a lot about the danger of file uploading, I
decided to create a folder at the root of the web server. The upload of
the files goes on without any problem, but when i tried to show some of
the file (such as the image files), the system does not retrieve them.

Here is the the tree of my web server :
/.
/website (folder where all of the web site is build with *.php files)
/uploads
/images (folder where all the images files are uploaded)
/pdf (files where all the pdf files are uploaded)

The bit of code doing the uploads works fine, but I can not find a way
to retrieve the files. When I code in the php file :
echo '<img src="../uploads/images/test.gif">'
The browser is in fact looking for a file name
www.mywebsite.com/uploads/images/test.gif which of course does not exist.

View Replies !   View Related
File Upload Issue
I have a script that uploads files to my server. The script file is in the same directory as where I want the uploaded files stored. Does anyone know the syntax to tell the upload process to look in the same directory. I have the path $target_dir = "upload/"; and then $target_path = $target_dir . $filename;

The code crashes when it comes to: if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target_path))

View Replies !   View Related
File Upload - Mac / Jpg Issue
Not sure what's wrong here - basically have a file upload script that's been working fine, but a colleague has just been unable to upload a jpg on his Mac. It's not the file, as it works fine on a PC. The code:

View Replies !   View Related
PHP File Upload Issue
I am attempting to upload files via. PHP 4.4.4. The
'$_FILES['update']['tmp_name'][0]' resolves to '/tmp/phpey9MpD', but
when I go to the /tmp dir. I do not see any php* file.

Could this be a issue with PHP or unix permissions for the web server?

Code:

View Replies !   View Related
Upload File Type Problem
I developed a simple tool to allow users to upload .GIF image files.

It works great on my dev box and $_FILES['file']['type'] returns
"image/gif", but on the prod site it returns "application/octet-stream".

View Replies !   View Related
PHP/MySQL File Upload Issue
I have a working script where I upload a textfile to my server, then read it into my mysql database. I have only written this as a trial system so far, but it works apart for one thing I cant understand.

When I upload a file to my site (its a development box I have full control of) via ftp and read the file in to MySQL using the LOAD DATA.... command, the file is written to the table perfectly (or if I execute my php script to read data from file -> dbase). However when I upload it via my browser to the same directory on the server, the file somehow gets altered - and then when I insert the values into my table, the alignment is all a mess, whether I use my php script or the MySQL command line to insert the data file. If I download the browser-uploaded file via ftp or view it in vi on my server, it looks fine...

The contents of the file (plain text file, created in vi, notepad, anything) are just 2 things - a date and an item (both varchar fields) e.g.

021904 webmasterworld
021904 testing
... etc

The seperation string between the date and name has been tested as a space and a tab, neither fixes my problem. I have used a lot of different variants in my php insert statement - from simply "LOAD DATA LOCAL INFILE '/path/to/$myfile' INTO TABLE record (date, name)"; to trying FIELD TERMINATED BY etc - perhaps I just haven't hit the right combination yet?

Anyway to sum up:

View Replies !   View Related
Image Upload - Verify File Type Help
Im having trouble getting this to work, i want to validate that the uploaded image ($picture) is a gif or jpeg.

[php]
// Validate the image type. Should be jpeg, jpg, or gif.
$allowed = array ('image/gif', 'image/jpeg', 'image/jpg');
if (in_array($_FILES['picture']['type'], $allowed))
{
$errors['picture2'] = 'Please ensure the image is a JPEG or GIF.'
}
[/php]

View Replies !   View Related
Image Upload Wrong File Type
I make an image, save it as a bmp. If I change the file  extention to a .jpg it changes.

My site allows for uploads of jpg, gif, and png. Since the above is actually a bmp, and some one tries to upload it with the jpg file extention, I get this error message:

Fatal error: Call to undefined function imagecreatefrombmp() in /home/.marble/ryannaddy/tzfiles.com/guestLoad.php(11) : eval()'d code on line 1

How can I stop that error from showing, and make my own error message saying somthing about it still being a bmp file, or exe, or html, etc. and only jpg, gif, and png are allowed? Code:

View Replies !   View Related
MIME Type Validation For File Upload
I am trying to create a validation for my upload script that will only allow: "jpg" and "JPG" files to be uploaded. My script is below; can someone tell me what I am doing wrong and how to fix it - please? Code:

View Replies !   View Related
Verify Mime Type Of Upload File
In light of recent security concerns over PHP I've become extra paranoid. I was going to let users upload a CSV of their data for importing (eg: mailing list addresses) but I can't think of a way to verify that the uploaded file is actually a text file, or what the repercussions might be of trying to open a file of unknown type and trying to read it as CSV.

View Replies !   View Related
Upload Script - File Type Filter
i have a PHP upload script, that very much works, but it dosn't filter any file types out. i want to be able to block certain file types. or if thats not possible, then just specify which file types. Code:

View Replies !   View Related
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?

View Replies !   View Related
Capture And Store File Mime Type During Upload
I have a simple file upload script. but I want to capture and store the files mime type. What is the easiest way to do this?

View Replies !   View Related
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.

View Replies !   View Related
MIME-TYPE Issue?
I wrote a script that creates an email with 2 attachments. The PDF-attachment is no problem at all. The second one is supposed to be a message, which then can be opened and sent from any mail program. Now I ran into trouble...

The script and everything works fine using Outlook as reciepent. Netscape 6.2. just doesn't seem to recognize the attachment and opens the browser instead of the mail application to show it's content. I'm aware that this might not be a PHP-related problem. PHP Code:

View Replies !   View Related
Issue With Module Type
We are trying to use php through the command line on a fedora core 6 box. When we run our program we get the following error.

Module compiled with module API=20060613, debug=0, thread-safety=0
PHP compiled with module API=20050922, debug=0, thread-safety=0

These options need to match. I am not sure where to start looking for the problem, as all of the programs were just compiled 2 days ago, with the latest updates. This problem happens in both PHP4.4.4 and 5.2.x.

View Replies !   View Related
Content-Type Issue
I have changed my Content Type to be multilingual and I keep getting an error when sent

Here's the code:

<code>
$headers = $headers ."Content-Type: text/plain; charset="GB2312" Content-Transfer-Encoding: 7bit"

";
</code>

The error I'm getting back from that line is:

Parse error: parse error, unexpected T_STRING

in /home/site/public_html/referafriend_submit.php on line 45

how i'm miscoding the above line of code?

View Replies !   View Related
Content-Type Issue In E-mail Script
I have changed my Content-Type to be multilingual and I keep getting an error when sent
Here's the code i have in there:

<code>
$headers = $headers ."Content-Type: text/plain; charset="GB2312" Content-Transfer-Encoding: 7bit"

";
</code>

The error I'm getting back from that line is:

Parse error: parse error, unexpected T_STRING in /home/site/public_html/referafriend_submit.php on line 45

Anyone have any ideas on how i'm miscoding the above line of code?

View Replies !   View Related
Upload Audio Files Of Type .wav & Video Files Of Type .avi
I need to upload audio files of type .wav & video files of type .avi
/ .mov but my current file unloader is not helping me with that. My
unloader works with application types, images, txt, pdf , mp3, mpg,
mpeg but not with those .wav & .mov/.avi files........

View Replies !   View Related
Upload Issue - Tmp_name
The issue I am encountering is mainly to deal with tmp_name I have this html for to submit the file: PHP Code:

View Replies !   View Related
Image Upload Issue
I am trying to upload images only to a directory on my web server with very little success, Code:

View Replies !   View Related
Image Upload Unlink Issue
I have a site that uploads and formats an image to my website. Currently, when I add new, it uploads the image and names it by the ID associated with the subject (ie. 8.gif). The problem occurs when I go to modify the data. The current code I have unlinks the original URL then adds a new image with no name and just the .gif extension. It is supposed to remove the old image, replace the new and reset the link. Can someone look at my code and see if they see anything wrong? Code:

View Replies !   View Related
Image Type And Size Filter For Upload
I have this code that works well for me.Just need the added function to check that "uploadFile" is a jpeg, jpg, gif or png and is no bigger than a meg. Code:

View Replies !   View Related
Upload A File But I Always Get The Error Message: Possible File Upload Attack!
I'm trying to upload a file but I always get the error message: Possible file upload attack! Code:

View Replies !   View Related
File Upload Problems - Upload A File To The Server.
I am trying to upload a file to the server.
http://chops.novatrope.com/game/test/form2.html
Here is some more debugging info:Array
(
[userfile] =Array
(
[name] =Pequot.gif
[type] =>
[tmp_name] =>
[error] =3
[size] =0
)

)

I am usiing code from the php manual.
Here is the php info http://chops.novatrope.com/info.php

<?php
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
// of $_FILES.

$uploaddir = '/usr/home/arthur/public_html/game/test/uploads/'
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);

echo '<pre>'
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.
";
} else {
echo "Possible file upload attack!
";
}

echo 'Here is some more debugging info:'
print_r($_FILES);

print "</pre>";

?>

and here is my html

<!-- The data encoding type, enctype, MUST be specified as below -->
<form enctype="multipart/form-data" action="getfile2.php" method="POST">
<!-- MAX_FILE_SIZE must precede the file input field -->
<input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
<!-- Name of input element determines name in $_FILES array -->
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>

View Replies !   View Related
How Can I Check File Type Of The Local File?
How can I check file type of the local file. The file is already uploaded.

View Replies !   View Related
File Upload Problem - Upload Multiple Files
I'm trying to upload multiple files. I'm using the chm file from
php.net to help me figure it out. I also checked online and say theres a
problem with the file. Anyway My html looks like this:

View Replies !   View Related
File Type
i'm having a problem with a file type it's a news index file .nzb file i can upload it ok, and it's in my database as filename.nzb , i can see it on my server as filename.nzb , but when i go to download it to my desktop it turns into filename.xml, my files allowed code is:

$file_accepted = array("text/xml","application/octet-stream","application/x-gzip-compressed","application/x-xml");
through testing i have seen that the nzb's mime type is:

text/xml
is there anyway to download as an nzb , everytime i try i get filename.xml

View Replies !   View Related
Type For .PHP File
i found many ways to force download in PHP by googling. but i difficult to force download PHP file. I've searched mime type for php but nothing, just asp (text/asp). what is mime type for php file so i can force download .php file?

View Replies !   View Related
To Get A File Name, File Size, File Type...?
Is there a way to get information about a file BEFORE it is submitted to the server?
I am trying to make a upload progress bar from scratch WITHOUT THE PRON.C PHP FIX!!!
I found the file being uploaded in my NET://WINN01910//TEMP folder and I can outputs its file size in a popup with a one second refrehs, but this makes it so the USER needs to know the full file size to know if its anywehre near done. 

Is there a way to get the filesize from the clients side?  Possibly javascript that uses ajax to submit the values to the server before the file is sent but when it is selected?? Is there an easier way to do this and/or do you have any ajax example code of how it might work?

I also have another problem, Althoguh i can echo the filesize of what is recieved so far, I am just glob()ing the temp folder for: "php*.tmp" but is there a way to tell the tmp file so they don't see everyone's uploads?

View Replies !   View Related
FILE Type For MySQL ?
Is there a FILE type in MySQL??? to store files as a column in a registry of certain table?

View Replies !   View Related
File Type Is In The Array $ext Or Not
i have this array :

$ext=array ("image/pjpeg" , "image/jpeg" , "image/gif");

i wanna check if the file type is in the array $ext or not, i wrote this :

if($imgtype  !=$ext[0] or $imgtype  !=$ext[1] or $imgtype  !=$ext[2]){
    die("error");
}

the $ext maybe will have more file ext., so i need to change the if term always!

View Replies !   View Related
Determine The Type Of A File (gif Or Jpg)
I've written a very basic CMS using a PHP database thing (no MySQL). It lets me update a list of 5 descriptive texts, each relating to an image which is shown next to the text.

At the moment, my HTML looks like this (simplified):

<tr><td><img src="images/Picture1.gif"></td></tr>
<tr><td><img src="images/Picture2.jpg"></td></tr>
<tr><td><img src="images/Picture3.jpg"></td></tr>
<tr><td><img src="images/Picture4.gif"></td></tr>
<tr><td><img src="images/Picture5.gif"></td></tr>

which is very inelegant as I have to repeat all the information.
I've already written the script to create the 5 table rows dynamically, using a "for" loop with the counting variable $i, so that I can simply write one row and substitute the Picture number with the variable: PHP Code:

View Replies !   View Related
Checking File Type
I have a page where I can update some entries in a MySQL database and add a picture. The name of the file (added a timestamp) is stored in the database and the file it self in a directory. I have no problems in the uploading part or in database, but when i tried to add file type checking part it went wrong.

The only allowed type should be .jpg/jpeg, but even though it is possible to upload that type something strange happens when trying to upload a non .jpg: It don't return the $mess ("Wrong file-type"), but instead it jumps to the "IF($img == "none") part and inserts the text in database (which it shouldn't) as if the $img is empty! Code:

View Replies !   View Related
Input Type = File
If an input field of type 'file' is left blank, what is returned as the varible? I'm having a problem, I have two file fields and want to be able to do the following:

1. Put in the $file1_name and $file2_name (if there was a file uploaded) into a database so I can reference it later.

2. Copy the uploaded file (if, in fact, there was a new one uploaded) to a directory.

3. Later on, if someone wants to edit that entry and wants to upload a new file for the 2nd slot, or 1st for that matter or delete a file, it should do that with no difficulty.
I'm running into problems when it reaches the 'if' clause. I've tried:

if ($var){
and
if($var != ''){

and no matter what, for some reason these blank file fields alwasy evaluate true to my if statements, so I get an error like 'can't open file 'none' for blah blah'.

View Replies !   View Related
Mime Type Of A File?
How do I get the mime type of a file on the filesystem?

View Replies !   View Related
File Type Checking ...
i'm building a system where i'm uploading some files and checking
the right type of files. Now i'm only allowing the users to upload
pdf, msword and mspowerpoint files. But i need to allow them to
upload Excel, Txt and zip files also.

Can anyone please check and tell me how to do that. I'm using the
following code....

View Replies !   View Related
File Type Validation
I am writing a script for uploading files. I want the script to only accept certain filetypes, in order to avoid any bad content. I figured I could do it by checking the MIME-type, or perhaps the file-ending. However, there are quite a number of filetypes I would like to allow, and so I am wondering if I could get some pointers to a more elegant solution than simply "brute-forcing" my way through all the different filetypes.?

View Replies !   View Related
Check File Type
I use this to check my files type:

$fileextension = $_FILES['file']['type']; But it returns the files MIME type, such as image/x-png. How can I get it to check the files actual extension? Such as .mp3 and .zip etc.

View Replies !   View Related
Explode To Get File Type
I'm pretty baffled at this. I'm not entirely sure why this isn't working:

$filetype= $_POST['file']['type']; // getting the file type
$file  = explode('.', $filetype); // exploding the string to return just the file type
$filename        = rand() . '.' . $file[1]; // renaming it and then adding the file type back to save the file

I'm trying to retrieve the file type seperately and then rename it.

View Replies !   View Related
File Type/extension
Ive been trying to figure this out for a while now but I just can't find a function that does it the way it SHOULD. For example, if there is a file in a directory that has the extension *.php or *.html it would echo "php" or "html" .

This way when a member of the site tries to edit a file and save it as *.php the file manager will warn them that they cannot have that file type. I've tried using filetype() but that returns information that is irrelavant.

View Replies !   View Related
Put Value Of An Input Type File
im trying to query on the database and display the results as value of the input type file like this code below.

<input type="file" name="uploadfile" value="$row[filename]">

I was wondering why the value didnt appear, even if i try to put a <input type="file" name="uploadfile" value="testing">

anyone has idea how?

View Replies !   View Related
MIME Type Of Mp3 File
I'm uploading mp3 files and ofcourse checking the MIME type, and I would expect that the MIME type would be audio/mpeg or audio/x-mpeg. But, instead of that it recognizes the mp3 file as application/octet-stream.

How can that be? I deffinetly not want to allow that type as it would create a mayor security issue. checking for extension is also no option; that's easely bypassed.

Does it have something to do with de ID3v2 information in the beginning of the file? i know octet has got something to do with 7-bit stuff, and in ID3v2 tags are syncsave using 7-bit bytes.

View Replies !   View Related
FILES['file']['type']
im, currently working on a mutilmedia hosting script and we only allow certain file types jpg,gif,png for example what i want to know is should i rely on $_FILES['file']['type'] to determine the filetype or should i go with strripos() and rely on the file extension. i was concerned about going the file extension way simply because it doesnt take much to change a file extension.

View Replies !   View Related
Finding File Type
What is the best way to find out a file type of a certain file? I have a script I wrote that handles uploads, and I read somewhere (can't remember where) that relying on $_FILES['fileID']['type'] is not completely safe.

The files for the particular project I'm working on will just be images, jpegs to be exact, but I would like to write this in such a way that I can use it for other file types in the future (like zip files).

View Replies !   View Related
File Get Contents Issue.
In folder WWW i have text file named news.txt. I'm calling file_get_contents("news.txt"); form index.php in the same folder. I got error:

Warning: file_get_contents(news.txt): failed to open stream: No such file or directory in /home/www/index.php on line 14.

View Replies !   View Related
File Writing Issue
I am writing a file using PHP and all is great thus far:

[code....]

However I want to add the facility for the file to be written into a
sub directory that may or may not exist - if the folder exists then it
works fine - if it doesn't then it throws an error.

Without having to write a section of code to check if the folder
exists, is there a way of forcing PHP to build any required folders for
me?

View Replies !   View Related
Copy File Issue
Why does the below fail to create a copy of the template.php page? I want to assign the copy a new name and save it. Below gives the error : failed to copy template.php. Where am I going wrong? PHP Code:

$file = 'template.php' //TEMPLATE
             echo $newfile = $title.'.php' // COPY

             // copy over files
             if (!copy($file, $newfile)) {
                  echo "failed to copy $file...
";
             }
             else
             {
                    echo 'File Created.'

View Replies !   View Related

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