Jump to content

making upload form, file not uploading. HELP!!


m1k3yb0y

Recommended Posts

I have been spending the majority of this week figuring out why my files are not showing up at my upload location that I set up in my newly created simple upload form. It just seems like php doesn't like me at all. :'( Here is what my code looks like below.

 

<?php 
if (move_uploaded_file($_FILES['thefile']['name'], $upload_file))
$destination = "/www/zymichost.com/m/t/l/mtlproductions/htdocs/";
$upload_file = $destination . basename($_FILES['thefile']['name']);{
echo "Your file has been uploaded successfully!";
}/* else {
  echo "Your file did not upload successfully. Check to make sure your file meets the requirements and then try again.";
  print_r($_FILES);}*/?>

 

I have the orange marked areas commented out due to the unexpected T_ELSE error thing. What do I do to get my files to show up at my upload location when I use my upload form? Thanks!

Link to comment
Share on other sites

First and foremost, add this to the beginning of your script so you can see the errors

 

error_reporting(E_ALL);
ini_set("display_errors", 1); 

 

Then try this as a fix:

 

$destination = "/www/zymichost.com/m/t/l/mtlproductions/htdocs/";
// move_uploaded_file accepts a filename string and destination string and if you're uploading it from a form, you'll use tmp_name
if (move_uploaded_file($_FILES['thefile']['tmp_name'], $destination) === false) { // returns a bool value
    // your error handling here
} else {
    // your success handling here
}

Link to comment
Share on other sites

Alrighty guys, now that my weekend is over, I went and tried out your suggestions. First off DevilsAdvocate, my hosting does not allow access to the php.ini file as well as that function due to security. And the adjustments you made to my code, it worked great! :thumb-up: I saw my uploaded file at my destination! However, I attempted to see if it would upload to my uploads folder that I have in the same folder as my uploaded file. Well....no luck thanks to this:

 

Warning: move_uploaded_file(/www/zymichost.com/m/t/l/mtlproductions/htdocs/Uploads/pho_gallery_MX5_ext1.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /www/zymichost.com/m/t/l/mtlproductions/htdocs/processfiles.php on line 4

 

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/www/zymichost.com/m/t/l/mtlproductions/htdocs/phpEmKcaP' to '/www/zymichost.com/m/t/l/mtlproductions/htdocs/Uploads/pho_gallery_MX5_ext1.jpg' in /www/zymichost.com/m/t/l/mtlproductions/htdocs/processfiles.php on line 4

Is there a reason for that?

 

Proteu, how do you CHMOD the directory?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.