473,473 Members | 2,080 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Very strange file upload behavior

I tried to search for this issue on the group, but don't even know
where to start, so here's my problem.

We have a very simple form which has a file upload box.
Upon submit the file should be uploaded (using the copy function, from
the server's temp directory to our final directory), the database
should be updated, and the user should be notified of success/failure.
In that order. When we test it at the office, and even from a dial-up
at home, everything is fine.

When my client tries to do it from his cable modem connection here is
what happens: He chooses the file on the form, clicks submit and the
page churns away for a long while. Then, it just goes back to the form
page. In the meantime, the file has been moved to the server's temp
directory, but does not get to our final directory. The database gets
updated (which should only happen after the copy function), but no
confirmation message is given.

Here is some truncated code:

function upload_file()
{
global $target_dir,$target_file;
$upload_temp = $_FILES['filename_new']['tmp_name'];
$upload_file = $_FILES['filename_new']['name'];
$target_dir = "../downloads";
$target_file = $target_dir . "/" . $upload_file;

if (!copy($upload_temp, $target_file))
{
echo "<h4>Failed to upload file...<h4><br>\n";
die();
}
else
{
echo "<h4>Uploaded File Successfully...<h4><br>\n";
return;
}
}
upload_file();
$sql = "INSERT INTO downloads
(name,filename,sort_order,description,category,reg istration) VALUES
('".$name."','".$filename."',".$sort_order
..",'".$desc."',".$category.",".$registration.") ";

$result = mysql_db_query($glb_db,$sql) or die(mysql_error());

print "<p>The download has been added";
Jul 17 '05 #1
3 2081
po********@yahoo.com (Courtney L.) schrieb:
if (!copy($upload_temp, $target_file))


Use move_uploaded_file() instead.

Regards,
Matthias
Jul 17 '05 #2
I'll give it a try right away. But can you help me understand the
logic of why this is better?

Matthias Esken <mu******************@usenetverwaltung.org> wrote in message news:<bl**********@usenet.esken.de>...
po********@yahoo.com (Courtney L.) schrieb:
if (!copy($upload_temp, $target_file))


Use move_uploaded_file() instead.

Regards,
Matthias

Jul 17 '05 #3
po********@yahoo.com (Courtney L.) schrieb:
I'll give it a try right away. But can you help me understand the
logic of why this is better?


Read the documentation at
http://de3.php.net/manual/en/functio...oaded-file.php.

Their english is much better than mine. :-)

Regards,
Matthias
Jul 17 '05 #4

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

Similar topics

1
by: Muppy | last post by:
I've created a page with a form to upload files: <h1>Upload di un file</h1> <form enctype="multipart/form-data" method="post" action="do_upload1.php"> <p><strong>File da trasferire:</strong><br>...
1
by: Kareem Badr | last post by:
I was having permission problems, so I'm using a test file to make sure uploading works. upload.php successfully uploads a file to the images/bookcovers dir: <html> <form method="post"...
0
by: sstark | last post by:
Hi, I have a web/cgi script that allows users to upload a file to the web server. I want to only allow files up to a certain size, which is stored in $imageFileMaxSize (typically 75K). That part...
6
by: leonecla | last post by:
Hi everybody, I'm facing a very very strange problem with a very very simple C program... My goal should be to write to a binary file some numbers (integers), each one represented as a sequence...
8
by: Braky Wacky | last post by:
Hello, I have an ASP.NET webpage that uses an instance of System.Web.UI.HtmlControls.HtmlInputFile for uploading files to our server. I came across the documentation at MSDN for upping the...
6
by: Vic Spainhower | last post by:
Hello, I am trying to do a FTP file upload which works fine on my localhost but on my ISP server it fails. I can't seem to find where I can go to find the specific cause of the failure. In both...
112
by: Prisoner at War | last post by:
Friends, your opinions and advice, please: I have a very simple JavaScript image-swap which works on my end but when uploaded to my host at http://buildit.sitesell.com/sunnyside.html does not...
1
by: pitjpz | last post by:
We have moved our Database to another server. The server it was on used SQL 4 and the new one its on now uses SQL5 the only problem we can find is that when you attempt to delete a record from...
10
by: Kal | last post by:
I recently installed Windows 2008 Server to replace a crashed hard drive on a web server with a variety of web pages including several classic ASP applications. One of these makes extensive use of...
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
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,...
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,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...
0
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...
0
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 ...
0
muto222
php
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.