473,320 Members | 1,846 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,320 software developers and data experts.

existance of a file

hello scholars,

i am just learning PHP. i have a small requirement in urgency.i want
to create a functionality of archiving in which a user can upload any
file through a browser to a location. but in that functionality. I
want to solve a small error in my program.The case is explained
below....

If i type the path,currently my program dont check for existance of
the file.ie; even if the file exist or not, the results appears as
"File uploaded successfully".
I need to know if there is any function in PHP to verify if the file
existed or not.Can any one help me to solve this small problem.

pls do help me...
Cherrish Vaidiyan
Jul 17 '05 #1
3 2013
if (file_exists("<name/path of file>")) {
<action>
}
"Cherrish Vaidiyan" <un***************@yahoo.com> wrote in message
news:f0**************************@posting.google.c om...
hello scholars,

i am just learning PHP. i have a small requirement in urgency.i want
to create a functionality of archiving in which a user can upload any
file through a browser to a location. but in that functionality. I
want to solve a small error in my program.The case is explained
below....

If i type the path,currently my program dont check for existance of
the file.ie; even if the file exist or not, the results appears as
"File uploaded successfully".
I need to know if there is any function in PHP to verify if the file
existed or not.Can any one help me to solve this small problem.

pls do help me...
Cherrish Vaidiyan

Jul 17 '05 #2
Cherrish Vaidiyan wrote:
i have a small requirement in urgency.
Then, with respect, usenet isn't the place.
i want to create a functionality of archiving in which a user can upload any
file through a browser to a location. but in that functionality. I
want to solve a small error in my program.The case is explained
below....

If i type the path,currently my program dont check for existance of
the file.ie; even if the file exist or not, the results appears as
"File uploaded successfully".
I need to know if there is any function in PHP to verify if the file
existed or not.


The file_exists function has already been suggested:

http://www.php.net/manual/en/function.file-exists.php

But the Manual entry for "Handling file uploads" says, "If no file is
selected for upload in your form, PHP will return
$_FILES['userfile']['size'] as 0, and $_FILES['userfile']['tmp_name']
as none.".

http://www.php.net/manual/en/features.file-upload.php

Moreover, move_uploaded_file will return false if its first parameter
is not a "valid upload file".

http://www.php.net/manual/en/functio...oaded-file.php

--
Jock
Jul 17 '05 #3
John Dunlop wrote:
The file_exists function has already been suggested:


Well, I forgot that even if the file doesn't exist on your system, by
typing a filename in, a file is created and store in upload_tmp_dir.
Say I type in "C:\My Documents\file.txt" (possibly including the
quotes; presumably users are familiar enough with their browsers to
know how to handle them) and it doesn't exist, file information is
still stored in $_FILES, since $_FILES just contains POST data.
That's only logical.

The is_uploaded_file function therefore returns true; the
move_uploaded_file function moves the file; the original name,
temporary name, type and size are set; and no errors are given.
That's all to be expected.

The size is obviously 0. Maybe you could check that. Otherwise, I
don't believe there is any other tell-tale signs.

Ref.: http://www.ietf.org/rfc/rfc1867.txt

--
Jock
Jul 17 '05 #4

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

Similar topics

1
by: Patrick Kowalzick | last post by:
Hello all, I want to test run-time if a template function for a special type exists. See example below. The checkfoo function is where I need some hints. Regards, Patrick #include...
3
by: Fabian | last post by:
How can I check whether or not a variable exists in a script? I'm thinking in terms of if (my variable exists) { myfunction(); } -- -- Fabian Visit my website often and for long periods!
4
by: lyndon hughey | last post by:
I'm having a problem setting the testing for the existance of a nodes outerxml property. Below I try to test for the existance before I access the property, but I receive a null exception error. ...
7
by: Ajit | last post by:
Is there anyway to check for existance of a file on different machine. i.e. we have a data file (text file) thats stored on some other machine as its not to be exposed in case the web server is...
4
by: Iain Porter | last post by:
Hi all, I have a usercontrol (a textbox with dropdown calendar that fills the textbox with the selected date) that I implement in a datagrid in a webform. On first loading the page, the datagrid's...
7
by: tonelab | last post by:
I currently have VS2003 .net 1.1 installed with a number of 1.1 projects built in it. All of these projects create the /bin dll for deployment and have been running on remote servers that have the...
6
by: Jm | last post by:
Hi all Im a bit of a newbie to VB.NET. Under vb6 if i used a class library DLL and it wasnt available i could use the on error resume next to get past the code that calls it and trap it...
2
by: allavarapu | last post by:
Hi All, How can we found whether directory or/and file existed in linux filesystem . In shell script to check file existance : if and Directory existance using if . Than how can we check...
1
by: Cirene | last post by:
Using VB.NET (latest version) I want to log onto an FTP server and check for the existance of 10 files in 3 different directories. I would prefer to do this over 1 live connection. Anyone have...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.