I have developed a small web app locally and all is working fine. Part of the functionality allows the user to upload MP3 files. Locally this all works fine and the files are moved to correct directory and can be played back. In heroku everything seems to work except the files aren't there.
My code...
Markup:
<form class="form" action="../model/process-track-upload.php" method="post" enctype="multipart/form-data">
<div class="row">
<div class="col-xs-12 col-sm-4">
<div class="dashboard-widget">
<h3>Add a song to your collection</h3>
<input class="input" type="text" name="trackname" placeholder="Track Name" required/>
<input class="input-margin" type="file" name="pic" />
<input type="hidden" name="userID" value="<?php echo $userID ?>" />
<button class="btn btn-large btn-block " type="submit" name="btn-upload">upload</button>
</div>
</div>
</form>
PHP:
if(isset($_POST['btn-upload']))
{
$pic = rand(100,1000000)."-".$_FILES['pic']['name'];
$pic_loc = $_FILES['pic']['tmp_name'];
$folder="../tracks/uploads/";
if(move_uploaded_file($pic_loc,$folder.$pic))
{
?><script>alert('successfully uploaded');</script><?php
}
else
{
?><script>alert('error while uploading file');</script><?php
}
}
I'm not awesome with environment configuration etc so it may be something going on there.
I should add as a note that files I added locally are available when I push to Heroku. It's only files that I add using the Heroku based version of the app that aren't getting saved in the correct (or any) directory.
Thanks