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

Strange Upload Problem

I am creating a php script that I can call from a delphi program, this
itself is easy as I have already done this. The problem lies within
the php script, here is the code that DOESN'T work:

<?
$temp = $_POST['userid'];
$uppath = "users/$temp";
clearstatcache();
if(file_exists($uppath)){
unlink($uppath);
}
if(copy($imgname, $uppath)){
print("done_upload");
}else{
print("failed_upload");
}
?>

KEY: userid will be something like '5.jpg' without quotes, so uppath
will be something like 'users/5.jpg'.

This is the error responce from the script, sorry its in a raw state:

<br />
<b>Warning</b>: copy(users/5.jpg
): failed to open stream: Invalid argument in <b>C:\Program
Files\Apache Group\Apache2\htdocs\messenger\up.php</b> on line
<b>8</b><br />
failed_upload

NOW, if I hardcode the uppath to 'users/5.jpg' NOT using userid to
complete the path this works - Weird, example below:

<?
//$temp = $_POST['userid'];
$uppath = "users/5.jpg";
clearstatcache();
if(file_exists($uppath)){
unlink($uppath);
}
if(copy($imgname, $uppath)){
print("done_upload");
}else{
print("failed_upload");
}
?>
I can't understand why I can hardcode the path, which is the same as
the one made up using the userid, and it works perfect.

The path I make using userid when printed out is correct and the file
exists cos I have checked this using a file_exists() check.

Any help is appreciated

Thanks

Ian
Jul 17 '05 #1
2 1853
Ian Hardcastle wrote:
I am creating a php script that I can call from a delphi program, this
itself is easy as I have already done this. The problem lies within
the php script, here is the code that DOESN'T work:

<?
$temp = $_POST['userid'];
Maybe there's some extra characters in the POST variable
$temp = trim($temp);

$uppath = "users/$temp";

[snip]
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #2
Thanks Pedro the trim() function seemed to fix the problem. There must
have been some invalid characters or blank space that didn't show up
when output so the comparison looked the same.

Thanks again, if only all problems were as simple to fix.

Later
Jul 17 '05 #3

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

Similar topics

3
by: Courtney L. | last post by:
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...
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>...
5
by: Shapper | last post by:
Hello, I just upload my web site to my hosting server and when I access it I always get an error: "Redicterion limit for this URL exceeded. Unable to load the requested page" Does anyone...
2
by: Alex Grefu | last post by:
Hello everyone! I have a problem that it's gonne drive me crazy... I have an intranet web application that has an upload module. I did it, test it and it's working on my development...
3
by: mikecom | last post by:
Hi Maybe there is an oracle out there who can help. I have an aspx site and a simple fileupload control on it. Everything works fine except: I can reproduce an 404 error when trying to upload...
2
by: ELINTPimp | last post by:
Hello all, Have a really interesting problem (at least to me) with my upload_file() function. I have it working now, with a bit of a work around, but would like to know what everyone thinks in...
3
by: macca | last post by:
Hi people! I'm having a problem with a file upload script that I'm writing. It works with Firefox but not Internet explorer. When the form is submitted(to it's self) it check for a file upload...
2
by: =?Utf-8?B?TmV0YWpp?= | last post by:
Hi Experts We are uploading files on the server using HtmlInputfile control with visual studio 2005, 2.0. In this there is an option for user to keep on uploading the files finally file actually...
8
by: Rinaldo | last post by:
Hi, When I start my program in the debugger, there is no problem, but when not I get an exception. It appears in: private void Upload(string filename, string FTnaam) { MessageBox.Show("in...
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...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.