TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 09-29-2009, 10:38 PM   #1 (permalink)
The Visitor
 
Join Date: Sep 2009
Posts: 4
Thanks: 3
ilangostl is on a distinguished road
Default copy(upload/100_0376.JPG) [function.copy]: failed to open

Now this is a new problem. I am trying to upload files. (This PHP application is in the following location on my Mac OS system: ~/Sites/samplesite2

So I am trying to do an upload and this is the error I get:
Notice: Undefined index: ufile in /Users/S/Sites/samplesite2/filebrowser/multiple_upload_ac.php on line 6

Notice: Undefined index: ufile in /Users/S/Sites/samplesite2/filebrowser/multiple_upload_ac.php on line 7

Notice: Undefined index: ufile in /Users/S/Sites/samplesite2/filebrowser/multiple_upload_ac.php on line 8

Warning: copy(upload/100_0376.JPG) [function.copy]: failed to open stream: Permission denied in /Users/S/Sites/samplesite2/filebrowser/multiple_upload_ac.php on line 11

Observations: Is this something to do with file permissions?
I set 777 for filebrowser, Sites, the upload folder, etc.

Or does this whole application go into some other apache2 folder?
Thanks in advance

The file pointed to is below:


<?php
//set where you want to store files
//in this example we keep file in folder upload
//$HTTP_POST_FILES['ufile']['name']; = upload file name
//for example upload file name cartoon.gif . $path will be upload/cartoon.gif
$path1= "upload/".$HTTP_POST_FILES['ufile']['name'][0];
$path2= "upload/".$HTTP_POST_FILES['ufile']['name'][1];
$path3= "upload/".$HTTP_POST_FILES['ufile']['name'][2];

//copy file to where you want to store file
copy($HTTP_POST_FILES['ufile']['tmp_name'][0], $path1);
copy($HTTP_POST_FILES['ufile']['tmp_name'][1], $path2);
copy($HTTP_POST_FILES['ufile']['tmp_name'][2], $path3);

//$HTTP_POST_FILES['ufile']['name'] = file name
//$HTTP_POST_FILES['ufile']['size'] = file size
//$HTTP_POST_FILES['ufile']['type'] = type of file
echo "File Name :".$HTTP_POST_FILES['ufile']['name'][0]."<BR/>";
echo "File Size :".$HTTP_POST_FILES['ufile']['size'][0]."<BR/>";
echo "File Type :".$HTTP_POST_FILES['ufile']['type'][0]."<BR/>";
echo "<img src=\"$path1\" width=\"150\" height=\"150\">";
echo "<P>";

echo "File Name :".$HTTP_POST_FILES['ufile']['name'][1]."<BR/>";
echo "File Size :".$HTTP_POST_FILES['ufile']['size'][1]."<BR/>";
echo "File Type :".$HTTP_POST_FILES['ufile']['type'][1]."<BR/>";
echo "<img src=\"$path2\" width=\"150\" height=\"150\">";
echo "<P>";

echo "File Name :".$HTTP_POST_FILES['ufile']['name'][2]."<BR/>";
echo "File Size :".$HTTP_POST_FILES['ufile']['size'][2]."<BR/>";
echo "File Type :".$HTTP_POST_FILES['ufile']['type'][2]."<BR/>";
echo "<img src=\"$path3\" width=\"150\" height=\"150\">";
?>
ilangostl is offline  
Reply With Quote
Old 09-30-2009, 12:45 AM   #2 (permalink)
The Contributor
 
ioan1k's Avatar
 
Join Date: Mar 2009
Location: US
Posts: 76
Thanks: 0
ioan1k is on a distinguished road
Default

Couple of things here
  1. $HTTP_POST_FILES has been deprecated since about 4.1 I believe you need to use instead $_FILES
  2. For uploaded files you want to use move_uploaded_file instead of copyand do a simple if statement using http://us2.php.net/getimagesize]getimagesize to validate that the uploaded file is an image
  3. You cannot process the form with three files being uploaded with the same name, each image you upload must have unique name so it would become $_FILES['ufile1], $_FILES['ufile2'] etc etc...
  4. You need to set write permissions to the folder you are uploading (777)
__________________
My Portfolio - Work - Need freelance Work?
I've been developing 5 years now, and I learn something new everyday
ioan1k is offline  
Reply With Quote
The Following User Says Thank You to ioan1k For This Useful Post:
ilangostl (10-01-2009)
Old 10-01-2009, 03:02 PM   #3 (permalink)
The Visitor
 
Join Date: Sep 2009
Posts: 4
Thanks: 3
ilangostl is on a distinguished road
Default

Thank you. I am implementing those changes.
ilangostl is offline  
Reply With Quote
Old 09-30-2009, 10:04 AM   #4 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

And you need to use forum tags to wrap your code samples to stop the wall of text crit my eyes have just experienced.


Edit ... GRRRRRRRR damn forum striped out my tags (and I did try to convert the [ ] o html entities), anyway this thread should show what I meant.
Prettifying Pasted Code on TalkPHP
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)

Last edited by sketchMedia : 10-01-2009 at 03:07 PM.
sketchMedia is offline  
Reply With Quote
The Following User Says Thank You to sketchMedia For This Useful Post:
ilangostl (10-01-2009)
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking for partner(s) for open source framework Scottymeuk General 4 02-06-2009 12:05 AM


All times are GMT. The time now is 02:53 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design