473,405 Members | 2,349 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,405 software developers and data experts.

Strange file upload behavior

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" enctype="multipart/form-data" action="upload.php">
<input type="file" name="userfile">
<input type="submit" value="submit">
<input type="text" name="eh" value='meh&lt;'>
</form>

<?php
$source = $_FILES['userfile']['tmp_name'];
$dest = 'images/bookcovers/' . $_FILES['userfile']['name'];
if ( ($source != 'none') && ($source != '' )) {
move_uploaded_file( $source, $dest );
}
?>

</html>
Now, I use the same code in another php file. The file is in the same
dir as the file above, and has the same permissions. The pertinent
code is:

$source = $_FILES['small_image']['tmp_name'];
if ( ($source != 'none') && ($source != '' )) {
$dest = explode(".", $_FILES['small_image']['name']);
$dest = './images/bookcovers/' . $isbn . "_small." . $dest[1];
move_uploaded_file( $source, $dest );
$smallimg = 1;
chmod($dest,0644);
}

When I try to upload a file using the second php script, I get
permission errors:

Warning: move_uploaded_file(./images/bookcovers/0679728759_small.jpg):
failed to open stream: No such file or directory in
/home/chucknet/public_html/bookclub/addBook.php on line 120

Warning: move_uploaded_file(): Unable to move '/tmp/phpw93I5U' to
'./images/bookcovers/0679728759_small.jpg' in
/home/chucknet/public_html/bookclub/addBook.php on line 120
I'm really at a loss as to what could be causing this. Both scripts
have the same permissions and the same owner. Anyone have any
suggestions?
Jul 17 '05 #1
1 1927
Kareem Badr wrote:
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:

snip
$dest = 'images/bookcovers/' . $_FILES['userfile']['name']; Now, I use the same code in another php file. The file is in the same
dir as the file above, and has the same permissions. The pertinent
code is:
snip
$dest = './images/bookcovers/' . $isbn . "_small." . $dest[1];
Just a hunch, depending on the server and paths, an if include is used
etc;
Try changing the latter (not working) one to the same format as the
first:

$dest = 'images/bookcovers/' . $isbn . "_small." . $dest[1];
I'm really at a loss as to what could be causing this. Both scripts
have the same permissions and the same owner. Anyone have any
suggestions?


HTH

--
Suni

Jul 17 '05 #2

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...
6
by: Paul | last post by:
Hi there, When adding a "File Field" HTML control to an aspx page to facilitate file uploading, the following occurs: 1. You select a file that is larger than the allowed size limit. 2. Once...
4
by: welch | last post by:
while taking some rough disk performance measures on windows machines, and snooping with FileMon, i've noticed some odd behavior here's the little nul-writer i'm running: def writeTest(nBlocks,...
4
by: Matt Jensen | last post by:
Howdy I've got a rather strange issue occuring. I used forms based .NET authentication, although I'm also setting some session variables when people login. However, I've found when people use...
0
by: Raven Jones | last post by:
Heya all, I'm working on a web-based application (using ASP.NET and C# on .NET 1.1.4322, supporting only IE6 for Windows) that allows for file uploads. Screen real estate is at a premium, so I...
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...
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...
2
by: Mike Kober | last post by:
I am having issues with the File Upload control for sending files to the server via HTTP. The speed of the upload is often between 20kbs and 40kbs. If I use the LAN at work to the server, it...
3
by: markus.rietzler | last post by:
i want to do (multiple) file upload(s) and display a progress bar. with firefox and safari it is no problem at all. only IE makes some problems. my script is based on ajax-uploader, which can be...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...

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.