Jump to content
xisto Community
takashiro1405241549

Php Uploading Problem

Recommended Posts

I thought there's no trouble with it. But it warned

[b]Warning: copy(E:\yufeng\upload1) [function.copy]: failed to open stream: Permission denied in E:\yufeng\upload.php on line 16[/b]
What's wrong?

<html> <head> <title>uploading files</title> </head> <body> <div> <form enctype="multipart/form-data" name=myform method="post" action="upload.php"> uploading files:<input name="myfile" type="file"> <br /> <input name="submit" value="upload" type="submit"> </form> </div> <?php if(isset($submit)){ if($myfile!= "none"){ $upload_dir = "E:\yufeng\upload1"; $up=copy($myfile,$upload_dir); if($up==1){ print("Files were uploaded successfully!"); } else { print("file uploading failed!"); } unlink($myfile); } else{ print("You haven't select any files!"); } } ?> </body> </html>

Share this post


Link to post
Share on other sites

The script doesn't know what you want to move!

When a file is uploaded, it by default goes to the temporary directory with a temporary name. You have to tell the script to move the file from that directory and give it a name for this to work.

Also, even if this method were to work, you would still need to assign a value to $myfile like $myfile = $_POST['myfile'];

 

I'm afraid that the very best example of file uploads is at the PHP.net Website.

Chapter 38. Handling file uploads

 

This is by far the easiest way to do this and learn the functions required to make it work. This is the method most developers use.

 

The best part of this, the whole script is written for you and ready for modification.:blink:

 

vujsa

Share this post


Link to post
Share on other sites

Also you need to set the correct folder rights, you must chmod the folder where you want to upload your files and also the uploaded file itself.Best regards,

Edited by TavoxPeru (see edit history)

Share this post


Link to post
Share on other sites

As I see he is using windows OS to copy/move the file, so chmod'ing isn't required, but if it would be a linux machine or similar, changing permissions could be needed, as I know it depends on the configuration. ;]

Share this post


Link to post
Share on other sites

As I see he is using windows OS to copy/move the file, so chmod'ing isn't required, but if it would be a linux machine or similar, changing permissions could be needed, as I know it depends on the configuration. ;]

Are you sure??? i think that he needs to set the correct permissions to do that -ok, not chmod because it isn't a *nix machine- in windows this is done by opening the security tab of the properties window of the folder. To open this you use the alt+enter keyboard combination or right click the folder, select properties and then click the security tab, after that you must give to the correct user the write and modify permissions apart of the read/execute and list permission, i'm not pretty sure but this is needed if the HD was formated with NTFS.
Best regards,

Share this post


Link to post
Share on other sites

wots ftp got to do with it?i use coreFTP lite :blink:well you could use it to CHMOD the folders but u dont need any special type of FTP program to do that.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.