Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I am new to PHP and javaScript, recently I move my site from localhost to a hosting site and the function move_upload_files stop working. My code is following:

PHP
<?php
include("includes/includedFiles.php");
?>

<form  method="POST" enctype="multipart/form-data">
Elige la cancion : <input type="file" name="files" >


<input type="submit" name="s" value="cargar" class="button">
</form>

<?php
if(isset($_FILES['file'])){
    $fileName=$_FILES['file']['name'];
    $fileName_temp=$_FILES['file']['tmp_name'];
    $upload="public_html/assests/music";
    $movefile= move_uploaded_file ($fileName_temp,$upload . $fileName);
    header("Location: https://ripleffect.net/uploadSong2.php?");
}
?>

When I try to upload a file, even a small file of a few kb instead of uploading it to the site and moving to the next page is stays there, I check the console and doesnt show me any error. My hosting site is hostgator.

Thanks in advance!

What I have tried:

I try to change $upload="public_html/assests/music"; to different things but nothing work, I try to change the name of the files and different kind of files and none of them worked
Posted
Updated 14-Oct-20 5:28am
v3
Comments
Chris Copeland 14-Oct-20 10:53am    
Several questions on the back of this code:

1. The $upload points to "public_html/.." but should this not be "/public_html/.." as this would normally be the root directory?
2. The $upload also points to "../assests/" which I would assume is meant to be called "assets" instead, are the directory namings correct?
3. The $upload ends with "../music" and then you're appending the filename to this. This would then try and create a file called "/public_html/assests/music<filename>", should the $upload not end with a "/" to indicate that it's a directory?
4. Have you checked the CHMOD permissions on the "assests" and "music" directories to make sure they have the necessary rights to be written to? Something like 0666 should provide read/write access to that directory.
drlink 14-Oct-20 11:05am    
1. I honestly dont know, I am new to php, and it might be wrong and it should be as you said
2. that is the actual name: assests , when I creted the folder I didnt realize that was misspeled
3. I don't know honestly, maybe?
4. and the music folder have 0755 permisions
Chris Copeland 15-Oct-20 4:42am    
Perhaps it might be worth trying to change the "public_html/" to "/public_html/" and also add a "/" onto the end of the $upload variable. I would think this should resolve your problem. You could also look at using the error_get_last() function to get information on what might have happened?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900