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




File Upload Script - Testing For Existence Of File


i'm having a strange problem when processing some form data. I just want to validate that required fields have been populated, then, if an image has been uploaded, i want to ensure that a description of the image has been provided (for alt tag purposes) before processing the data.

For some reason, when a file hasn't been attached, my script interprets it otherwise and prompts the user for the alt tag. I've not come across this problem before, there's a good chance i've done something idiotic but i just can't see it Code:




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Checking File Existence Through A List Of File Locations Gathered From An Array
I've been trying to wrote a code to check the existence of some files gathered from a field in mySql database.

And I am kind a stuck at a point where I get the file locations from the database but when it passes those locations to file exist it keeps telling me the file does not exist.

Only first file exists the other 2 file does not exist to test if the code was working or not. Code:

How To Check For Existence Of A File?
Im programming a shopping cart in php with an administrative back end. My question is this: whenever someone uploads an image for a product, I have to check if an image by the same name exists already. I've done this in perl before with a simple while

while(-e "/path/to/$image"){
//do my image renaming here}

The -e means while exists this file, keep renaming the current file until it has a unique name. So in php I've never done this before and Im trying to find out a good way to go about doing it. I've looked through the manual and cant really find anything.

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">

Email With File Attachements - How To Upload File To Server From Browser?
I have a PHP script that sends an email with attachment and works great when
provided the path to the file to send.

However this file needs to be on the same server as the script.

I want to develop a webpage where people can send attachments that are
stored on their local PC.

I know I can use the <input type="file" > HTML to generate a file box that
allows the user to navigate to a file on their PC and product a file path,
but how do I then upload this file onto file server to email out with my PHP
email script?

Is there an easy way to do this?

Or can I approach this problem from a completely different angle.

PHP File Upload Unexpected Error - File Too Large?
I have a short basic script to upload files. It works fine with small files,
but with longer files it gets stuck.

Here's the fragment, the input file is loaded in "$file" from an HTML form
as usual.

....
$img_str = fread(fopen($file, "r"), filesize($file));
$data = addslashes($img_str);
// --------------------- up to here the execution is correct and fast (<1
second)

$sql="INSERT INTO $table (".
" file_name,".
" file_type,".
" file_size,".
" bin_data)".
" VALUES (".
" '$file_name',".
" '$file_type',".
" '$file_size',".
" '$data')";
// --------------------- it gets stuck
here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
mysql_query($sql) or die ("SQL error ..$sql");

I have already set the php.ini variables as follows:
memory_limit = 16M
upload_max_filesize = 6M

I also checked the execution time to max_execution_time = 300 (even though I
don't believe it should be necessary).
The server is a P4 1.8 GHz, 256MB RAM

File Upload - Directory Is Writable, File Is Not
I'm writing a script to upload images along with articles to a
directory on the server. I'm developing it offline on my WinXP and
Apache 1.3.x laptop and it's working great, but when I move the script
to the server, I get write errors when the file attempts to upload.

So I set up a test script (included below) to test the directory
structures all the way up to the file, and every directory appears to
be writable, yet I can't write to the test file. I keep seeing
suggestions to set the open_basedir directive in the php.ini file to
solve this, but it's hasn't worked yet. Can anyone suggest what I can
try to get the uploads working?

<?php

$filename = 'images/articles/test.txt'
$somecontent = "Add this to the file";

......

File Upload Handling (file Types Etc.)
I have two questions. First, how can I control what files a user uploads? I can, of course, check the extensions but they can't always be trusted. Can I check the mime-types somehow? Second, is there a way I can set the "available formats" in the file upload dialog box?

File Upload Works But Only For Empty File
I can upload a file as long as it is empty (thanks Hendri Kurniawan).
I do not know where to look.

Can someone help me understand what I need to do to upload a small image.
http://chops.novatrope.com/game/test/upload_file3.php

Here is some more info http://chops.novatrope.com/info.php

I Can Not Get File Uploads To Show Up When I Upload A File
I've a form that starts off like this:

<form method="post" action="profile.php?
id=5&formName=my_story_edit.htm" enctype="multipart/form-data">

<p>Email address:<br />
<input type="text" name="totalFormInputs[users][5][email_address]"
value="lawrence@krubner.com" /></p>

<p>Zip code:<br />
<input type="text" name="totalFormInputs[users][5][zip_code]"
value="22902" /></p>

<p>Personal image:<br />
<input type="file" name="totalFormInputs[users][5][upload_file]" /></
p>

Oddly enough, the "upload_file" has suddenly disappeared from the
uploaded array. When I hit $totalFormInputs with print_r, this is what
I get:

Array
(
[users] =Array
(
[5] =Array
(
[description] =I grew up in New Jersey.
[email_address] =lawrence@krubner.com
[zip_code] =22902
[time] =1187380627
)

)

)

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?

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.

Upload File Gives A Blank File Name
I am having trouble with an upload script. Searched the forum but still couldn't fix it.
Here is the code: PHP Code:

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?

File Upload????
I need to upload mp3 files to either a database or a file. If it is uploaded to a directory, then I need somehow to put the address of the file into a database, can someone please guide me in this.

File Upload

I've tried to write a script to upload files. I'm using redhat and php3. I'm receiving the followind error:

Warning: Unable to create '/usr/local/apache/htdocs/rex/admin/test/html40.zip': Permission denied in /usr/local/apache/htdocs/rex/admin/test/test.php3 on line 40

What rights should i set ? I've tried all the combinations for owners and rights URL but it doesn't work....

File Upload
Here is the situation. I have a 'Comments' box on a HTML page where a user will enter some comments. Once the submit button is pressed, the comments show up on a PHTML page(summary).
I am now trying to place a File Upload option on the HTML page also, whereby I want the user to be able to enter comments, select a File, then only press 1 Submit button that will then show both the Comments and the File on the PHTML page.

File Upload
Hi,

I am writing an admin section for estate agent website and want only the authorised admin user(s) to be able to upload images to upload folder. I already implemented admin login through session variables. Is this enough or do you need to secure the upload folder as well?

How should you check that PHP has the correct rights
to write files to the secured folder you want to upload files/images to.

File Upload
I'm trying to get a file upload to work and it's not happening. Here's my
form code...

File Upload
I am using php3 and am trying to upload a file with the following code. When i try to upload it sets $filename to /var/tmp/phpDAA...

I don't know why it's doing this. Anyone have any ideas on how to fix this? I do not have access to / my private directory is in /opt2/company_name/ ,more info code:

File Upload
Hi all, this might be more of an html question but I think it can be done in
PHP, so I will ask here.

I have an html form that allows for .pdf file uploads. This script will
serve two functions 1) upload a .pdf file to a specific directory on the web
server and 2) create an entry into the db that includes the name of the file
just uploaded. I want to have another web page that will dynamically list
all of the names of the files uploaded as clickable hyperlinks so they can
view those .pdf files.

I have the file upload code working just fine, but the name that gets
written to the database as something like: "/tmp/phpTg2toF", which is not
the name of the file. How can I "get" the name of the file that I upload so
that it can be written into the db as a file name? Anyone have ideas? Thanks
in advance. Here is my code:

File Upload
I am trying to create a page with a file upload dialog box and am using the following code -

[html]
<FORM METHOD=POST ENCTYPE="multipart/form-data" ACTION="showname.php">
File to upload: <INPUT TYPE=FILE NAME="upfile"><BR>
<INPUT TYPE=SUBMIT VALUE="Submit">
</FORM> [/html]

The showname.php page is :

<?
$filename=$_POST['upfile'];
print "File name is $filename";?>

When I do this the $filename is reported as a null string. Even if I do not use the choose button and just type in text in the box, I still get nothing. If however, if I remove the "TYPE=FILE", so that the first page is a normal text box, the result page shows whatever was typed in.

File Upload
I have 2 files, one is a HTML file with the code to create a Browae and Submit Button for uploading a file. (This works fine). BUT, when I click the submit button, I want the file to upload to a directory on my C:/ drive which I have indiciated in the PHTML file, but I keep getting the following error and I don't know why.

Warning: Unable to open 'php2' for reading: Unknown error in C:apachehtdocs/submitassprac.phtml on line 5 Couldn't copy the file! OR

Warning: Max file size exceeded - file [img1] not saved in C:apachehtdocs/submitassprac.phtml on line 0 Code:

File Upload
i'm using php 4.2.1, iis and win2kpro. my problem is when i try the file upload, my image is not uploaded to the folder. PHP Code:

File Upload
ok, I have a file upload secton to my site, two pages, one with a
form and one that does the uploading.... some files upload fine, other
don't

an exe of 300k will upload, but a word document of 40k wont and so on,
in the php.ini a limit of 2mb is set (I haven't changed it, it's how
the file originally as, so it isn't my maths that's gone mad).....

File Upload
I have a form containing text input, checkboxes and a file upload (all in
one form). The file has the a name = foto. When I try to check the name of
the file in nieuwsVoegToe.php I get Notice: Undefined index: foto in
C:InetpubwebpubNavigatorhtmlpublic_html
ieuw sVoegToe.php . I use
$_naam = $_FILES['foto']['name']; to get the name of the file. Someone knows
wat's going wrong?

// THE UPLOAD FORM
<form name="nieuws" method="post"
action="nieuwsVoegToe.php?actie=nieuw&IDN=">
Titel <input class="grijs" name="titel" type="text" size="40">
<textarea class="grijs1" name="inhoud" cols="80"
rows="8"></textarea><br><br>

foto toevoegen? <input name="fotoToevoegen" type="checkbox" value="1"
onSelect="EnableInput();"><br>
<table class="grijs" bgcolor="#EEEEEE" >
<tr><td>
selecteer je foto:
<input type="hidden" name="MAX_FILE_SIZE" value="20000">
<input type="file" name="foto">
</td></tr>
<tr>
<td>
// radiobuttons here
</td>
</tr>
</table><br>
<input class="grijs" type="submit" value="nieuws toevoegen >>">
</form>

File Upload
I cant get my php script to upload a file to the default dir. I have
checked all the php.ini variables and made sure there is a default
temporary dir, as soon as i submit it just reloads the page. this is my
form

<form enctype="multipart/form-data" action="<?php echo
$_SERVER[PHP_SELF]; ?>" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>

Upload A File
I am trying to upload a file to a folder in my c: drive but i get a stupid error I am doing this for the first time. Can anyone send me a simple script to upload a file to a folder? Code:

File Upload
The problem is everytime I upload an image/spreadsheet/etc... the file comes back corrupted. You'll notice if you try to upload an image that when it shows the image it is distorted. I also find it strange that the image seems to be double the original size everytime. Source code is attached to the document. I am having this problem with copy() also.

File Upload
I'm currently trying to get a file upload form to work, the original I started with came from this sites tutorial.. No matter what I tries, I gets messages like "Warning: Unable to create '/images/': No such file or directory in /Users/victor/Sites/foto/upfile.php on line 33"

/images has 777 properties. The form code is:

File Upload
I've had a script working that uploads a file. Now, since upgrading to PHP 4.3 and Apache 2.0.44, the input field's name-variable key doesn't even show up: $_FILES[$key]["name"], but all other variables from the form are coming in just fine.
Is there something new to php 4.3?

PHP File Upload
I am using the following functions to upload an image, and store it to the database. the format for the image in database table is mediumblob. PHP Code:

File Upload
I’m getting the following errors when I try to run the script below on a live server. It’s a crude script which uploads text and images directly into MySQL. It works fine on my local machine, I have Apache, PHP4 and MySQL running on windows. The live server is Unix.

When I try to upload images from my loacal pc I get the error below, when I placed an image file within the same directory as the script on the live server and tried to upload it that worked. I wanted the script to allow image uplload from a client pc Can anyone offer a suggestion?

Warning: fopen("C:Apachehtdocs Grey.jpg", "r") - No such file or directory in /usr/local/home/httpd/vhtdocs/sitehostin/moondance/backend/test_imagedb.php on line 57
Code:

MP3 File Upload
I am trying to set up a pod-casting administrative service for a
client, but seem to be having troubles with the MP3 Uploads,
specifically, they don't upload!

My testing server for this specific problem is:

mp3.php simply print_r's the $_FILES superglobal.

Right now, I am not going for secure, just working! As you can see, the
array seems to have nothing in it, and I am getting really frustrated.

File Upload
I want to make a file upload using php, but everytime i get an error
"File name not given". Any hints why this is happening? I used a sample
from php.net, and other php sites, but all samples are basically the
same. Maybe someone from you has a good and working example?

File Upload
I am trying to create a script to upload a file. the problem is that I wish to upload the file to a separate server than the script is located on. The server receiving the files can't run php.

File Upload
i can upload small files. hoeever i cannot upload bigger files-but
max_file_size is set correctly. what can be wrong? is it connected witrh
my browser?

File Upload
I just just got a html/php file upload to work using the copy function, but copy() still returns false and prints the error message saying that the upload failed. It returns false even though the file has already been uploaded to the correct place. Here is my code:

if (!copy($userfile,"$newfile"))
{
print "Error Uploading File.";
exit();}

File Upload
Q1. i wonder can we get rid of "browse" button instead of the one textfield and one button beside?

<form name="form1" method="post" action="addevent.php3" enctype="multipart/form-data">
<input type="file" name="userfile" size="40" maxlength="100">
<input type="submit" name="submit" value="Add">
</form>

File Upload
I'm trying to upload an mpeg file to a folder created on a server running Apache. I have tested this code on my machine which has w2k and php 4 installed and it works fine. But when I try and run this on the server running Apache I get the following error:

Warning: Unable to create '/data/htdocs/elders/listing_vids/12445.mpeg': Permission denied in /data/htdocs/elders/branch/admin/realimage_man/do_upload.php on line 32
Can't copy breakdance3.mpeg to 12445.mpeg

Would anyone know what the problem is?

File Upload
I want to know how to read a file from my computer and not on the web server. For example, I upload the script to my web server and view it from my home computer. How can I make the script read the file from my computer? I am wanting it to read the file and write it to a new file with the same name on my web server.

Upload A File Without IE
I am able to upload a file with an HTML form submitting to a PHP script. That is fine for uploading with the browser, but I need to upload from a FoxPro application without opening the browser.

If I try to send the variables (file name) to the PHP script in the URL it fails. I believe this is to protect people from sites grabbing files they should not see. But how can I get around this security thing?

PHP 5 On IIS 6 File Upload
I have started running IIS 6 and PHP 5 and am experiencing a problem with
limited size on file upload.

The php.ini file has been altered for both post and upload sizes

I have checked the MetaBase.xml to increase the value for
AspMaxRequestEntityAllowed. I have seen a reference to
MaxRequestEntityAllowed but cannot find it anywhere.

I seem to be limited to files under 5mb but haven't found the exact limit
yet.

Can We Upload 100 MB File
Can we upload a video file of 100 MB using PHP on linux server?
What coud be the consequences of uploading such a big file?
Or do i need to use some 3rd party gateway?

Php File Upload
I have developed a guestbook using PHP, Mysql on apache server. I have
used Dreamweaver for designing the web page.My client uses Earthlink
web hosting. Apparently Earthlink supports PHP on UNIX platform and not
on Windows. But I have used Windows XP. Please let me know if I can
still upload the page. Also are there any free web hostings which allow
me to upload the above page.

Upload Big File
I am using a POST method to upload a big file (20M), I have already
set the max-upload-file = 30M in php.ini and have the hidden
MAX_FILE_SIZE=30M in multipart form. However, it still refuse to upload
such file. For some reason, I am not going to use ftp instead. Any
idea?

How Do Upload A File From One PC To Another PC Using PHP?
I tried to upload a file from one pc to another pc using PHP. I didnt able to upload that file. But, I was able to upload a file to FTP or local directory. Can you provide the PHP script for upload a file to remote PC?. I have attached the sample code. Please correct that code:

Php File Upload
In file uploading (through a form usig browse button) It is not possible to access the temporary folder where tmp file is created.

The file doesnt get uploaded and hence cannot see the uploaded file in the directory.
An error appears as the file doesnot exists in the folder.

i couldnt set the permission also I use php 4 version. It works fine in local test server. But in main server it doesnt.

$file=$_FILES['file_cv']['name'];
$tmpfile=$_FILES['file_cv']['tmp_name'];
if(!empty($file)) {
$uploaddir = "accountantscv/$file";
move_uploaded_file($_FILES["file_cv"]["tmp_name"], $uploaddir);}   

File Upload
I am trying to have a file uploaded into a directory, based on user input. If the folder they are uploading to doesn't exist, it is created. The only thing I can think of, is that this method of file uploading will only work to 1 folder deep. That is only a guess though. Also the "destination" will only be 1 word long. Code:

File Upload
I'm really stuck with the file upload. I submitted similar code a while ago in MSSQL section , but didnt get any reply at all so i've change the code but am still having problems. Some one please help.

I'm running PHP 4.4, IIS 5.1 and mssql

Ok, i'm uploading a PDF file to a directory, the upload works fine but when I download the file I get an eror "cannot open the file it may be corrupted". It really bugging me, I cannot figure out why its not working. the PDF files that I upload are fine but when I upload it I cant open them again. Code:


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